ungleich-user/Dockerfile
Sajeyks 9e31854544 Build static files without mounting the dev env file
collectstatic only needs the five required settings now, so the build
passes placeholders for that one command instead of bind-mounting
dev/env.dev. The build context no longer needs dev/ at all. Also point
the header comment at migrate_locked and keep compose.yaml out of the
build context.
2026-11-11 21:36:03 +03:00

44 lines
1.4 KiB
Docker

# syntax=docker/dockerfile:1
#
# Production image for the ungleich account webapp.
# All configuration comes from environment variables: see docker.md and
# .env.example.
#
# docker build -t ungleich-user .
# docker run --env-file .env -p 8000:8000 ungleich-user
#
# Database migrations are not run on start; run them once per release:
# docker run --env-file .env ungleich-user python manage.py migrate_locked
FROM python:3.15-slim-trixie
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Security updates for the base image. No sshd or compiler is installed:
# every Python dependency ships as a pure Python or binary wheel.
RUN apt-get update \
&& apt-get upgrade -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --system --uid 10001 --no-create-home --home-dir /app app
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY manage.py gunicorn.conf.py ./
COPY dal ./dal
# Settings need the required variables to load; these placeholders exist
# only for this one command and are not part of the image's environment.
RUN SECRET_KEY=build LDAPSERVER=ldap://build LDAP_ADMIN_DN=build \
LDAP_ADMIN_PASSWORD=build EMAIL_FROM_ADDRESS=build@example.com \
python manage.py collectstatic --noinput -v0
USER 10001
EXPOSE 8000
CMD ["gunicorn", "dal.wsgi:application"]