Files
max/Dockerfile
T
finnandClaude Opus 5.5 f46a346078 Show the version in a footer for logged-in users
The version is read once at startup from the VERSION file, which is now
also copied into the Docker image. The footer is right-aligned below the
content block and only shown to logged-in users, so anonymous visitors
do not learn the exact version.

The startup log now has "Max starting." at the beginning of main() and
"Max initialized, version X." at the end, so a failed startup is visible
by the missing second line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 17:43:02 +00:00

43 lines
1.3 KiB
Docker

# Build stage: compile the wheels (psycopg2 needs gcc and libpq-dev)
FROM python:3.15-slim-trixie AS build
RUN apt-get update && \
apt-get install --no-install-recommends -y gcc libc-dev libpq-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY requirements.txt .
RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
# Runtime stage: no compiler and no tools besides what db-setup.sh needs
FROM python:3.15-slim-trixie
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y libpq5 postgresql-client wait-for-it && \
rm -rf /var/lib/apt/lists/*
COPY --from=build /wheels /wheels
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels
RUN groupadd --system --gid 10001 max && \
useradd --system --uid 10001 --gid max --no-create-home --shell /usr/sbin/nologin max
WORKDIR /app
ENV PYTHONPATH=/app/
ENV FLASK_APP=max.app
# Refuses to start in debug mode, see max/app.py
ENV MAX_PRODUCTION=1
# Owned by root, so the app cannot modify its own code
COPY max/ ./max
COPY scripts/prod/ .
COPY VERSION .
# Precompile, since the app cannot write __pycache__ at runtime
RUN python -m compileall -q max
USER max
ENTRYPOINT ["./entrypoint.sh"]
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:8000", "max.app:app"]