# Stage 1: General debian environment FROM debian:stable-slim AS linux-base # Assure UTF-8 encoding is used. ENV LC_CTYPE=C.utf8 # Location of the virtual environment ENV UV_PROJECT_ENVIRONMENT="/venv" # Location of the python installation via uv ENV UV_PYTHON_INSTALL_DIR="/python" # Byte compile the python files on installation ENV UV_COMPILE_BYTECODE=1 # Python verision to use ENV UV_PYTHON=python3.12 # Tweaking the PATH variable for easier use ENV PATH="$UV_PROJECT_ENVIRONMENT/bin:$PATH" # Update debian RUN apt-get update RUN apt-get upgrade -y # Install general required dependencies RUN apt-get install --no-install-recommends -y tzdata \ libpango-1.0-0 \ libpangoft2-1.0-0 \ libjpeg-dev \ libopenjp2-7-dev \ libffi-dev \ libpangoft2-1.0-0 \ libcairo2 \ libpangocairo-1.0-0 \ libgdk-pixbuf2.0-0 \ shared-mime-info \ gettext \ tini \ uwsgi # Stage 2: Python environment FROM linux-base AS python-base # Install debian dependencies RUN apt-get install --no-install-recommends -y \ libpq-dev \ build-essential \ curl \ gcc \ sassc # Install uv COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv # Create virtual environment and install dependencies COPY pyproject.toml ./ COPY uv.lock ./ RUN uv sync --frozen --no-dev --no-install-project # Stage 3: Building environment FROM python-base AS builder-base WORKDIR /app COPY . /app # Build static files RUN python manage.py collectstatic --no-input # Compile translation files RUN python manage.py compilemessages # Stage 4: Webapp environment FROM linux-base AS webapp # Copy python, virtual env and static assets COPY --from=builder-base $UV_PYTHON_INSTALL_DIR $UV_PYTHON_INSTALL_DIR COPY --from=builder-base $UV_PROJECT_ENVIRONMENT $UV_PROJECT_ENVIRONMENT COPY --from=builder-base /app /app # Start the application server WORKDIR /app EXPOSE 8000 CMD ["docker/entrypoint.sh"]