diff --git a/Dockerfile b/Dockerfile index 45e6801..c99dae2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,18 +4,25 @@ FROM python:3.9-slim # Set the working directory WORKDIR /app -# Install dependencies +# Install system dependencies (including gettext for envsubst) +RUN apt-get update && apt-get install -y gettext && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# Copy the application code +# Copy the application code and template files COPY . . +# Copy the entrypoint script into the container and make it executable +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + # Set environment variables (can be overridden by .env) ENV FLASK_ENV=production # Expose the port (Gunicorn will run on 8000) EXPOSE 8000 -# Run the app with Gunicorn; use 3 workers (can be tuned via .env) -CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app", "--workers", "3"] +# Use the entrypoint script as the container's command +CMD ["/entrypoint.sh"] diff --git a/example.env b/example.env index 9ad20df..69dafe0 100644 --- a/example.env +++ b/example.env @@ -8,3 +8,4 @@ DATABASE_PATH=/data/scripts/guestbook.db GUNICORN_WORKERS=3 PID=1000 GID=1000 +SITE_TITLE="The Montana Dinosaur Center Visitor Log" diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000..ecd9ed7 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Process index.html.template to create index.html +# Adjust the path if your template is located somewhere else +envsubst < /templates/index.html.template > /templates/index.html + +# Start Gunicorn; using an environment variable for workers (default is 3) +exec gunicorn --bind 0.0.0.0:8000 app:app --workers ${WORKERS:-3} diff --git a/templates/index.html b/templates/index.html.template similarity index 95% rename from templates/index.html rename to templates/index.html.template index a0595f0..77d4bb4 100644 --- a/templates/index.html +++ b/templates/index.html.template @@ -4,7 +4,8 @@ - The Montana Dinosaur Center Visitor Log + ${SITE_TITLE} +