-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (27 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
40 lines (27 loc) · 1.19 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
FROM python:3.13-slim-bookworm AS installer
# The installer requires curl (and certificates) to download the release archive
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates
# Download the latest installer
ADD https://astral.sh/uv/install.sh /uv-installer.sh
# Run the installer then remove it
RUN sh /uv-installer.sh && rm /uv-installer.sh
# Ensure the installed binary is on the `PATH`
ENV PATH="/root/.local/bin/:$PATH"
WORKDIR /env/
COPY pyproject.toml uv.lock /env/
RUN uv venv .venv && uv sync
FROM python:3.13-slim-bookworm AS runner
WORKDIR /app
COPY --from=installer /env/.venv /.venv
COPY ./project /app
ENV PATH="/.venv/bin/:$PATH"
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# For some reason, you must run this locally because this doesn't generate the staticfiles correctly
RUN python manage.py collectstatic --no-input
RUN groupadd -r djangouser && \
useradd -r -g djangouser -s /usr/sbin/nologin djangouser && \
chown -R djangouser:djangouser /app
USER djangouser
EXPOSE 8000
CMD ["python", "-m", "gunicorn", "project.wsgi:application", "--bind", "0.0.0.0:8000", "--log-level", "debug", "--access-logfile", "-", "--error-logfile", "-"]