-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (30 loc) · 1.67 KB
/
Dockerfile
File metadata and controls
41 lines (30 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# syntax=docker/dockerfile:1.7
FROM python:3.12-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install system deps (curl for uv installer, build tools only if needed)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:${PATH}"
WORKDIR /app/efile_app
# Copy project metadata first for better layer caching (project now rooted at efile_app/)
COPY efile_app/pyproject.toml efile_app/uv.lock* ./
# Install dependencies without installing the project code yet (faster rebuilds)
RUN uv sync --frozen --no-install-project
# Copy the rest of the source code into /app
COPY . /app
# Install the project itself (editable-like install)
RUN uv sync --frozen
# Collect static files at build time so WhiteNoise can serve them at runtime
# Use staging settings to ensure DEBUG=False and STATIC_ROOT is set
# Provide a non-insecure SECRET_KEY for build to satisfy settings_staging
RUN DJANGO_SETTINGS_MODULE=efile.settings_staging \
DJANGO_SECRET_KEY=build-static-collect-key \
DATABASE_URL=sqlite:////tmp/build-collectstatic.sqlite3 \
uv run python manage.py collectstatic --noinput
EXPOSE 8000
# Use Gunicorn with Uvicorn workers (ASGI) and log to stdout/stderr (debug level)
CMD ["uv", "run", "gunicorn", "efile.asgi:application", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "--workers", "2", "--timeout", "60", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "debug", "--access-logformat", "%(h)s - %(l)s %(u)s [%(t)s] \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\" in %(L)ss"]