Files
bugsink/Dockerfile.fromwheel
Klaas van Schelven 786a97aaa0 Rename Dockerfile to Dockerfile.fromwheel
See #68 for discussion (which is summarized at the top of the Dockerfile)
2025-04-04 11:41:45 +02:00

50 lines
2.0 KiB
Docker

# This is the Dockerfile that builds an image given a specified WHEEL_FILE,
# rather than from source/working dir.
#
# The reason for this is that, although Bugsink is certainly available as a
# Docker image, it is available as a Python package first. We thus want
# the Docker image to be as faithful as possible to the Python package.
#
# Because the typical expectation for a Dockerfile is that it "just works"
# and that it builds from source (the working directory), the present file
# is not named Dockerfile, but an explicitly postfixed one. Still, for the
# purpose of what actually ends up on Docker hub, the present file is the
# one that's used.
ARG PYTHON_VERSION=3.12
# Build image: non-slim, in particular to build the mysqlclient wheel
FROM python:${PYTHON_VERSION} AS build
ARG WHEEL_FILE=wheelfile-not-specified.whoops
COPY dist/$WHEEL_FILE /wheels/
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
pip wheel --wheel-dir /wheels /wheels/${WHEEL_FILE} mysqlclient
# Actual image (based on slim)
FROM python:${PYTHON_VERSION}-slim
# ARGs are not inherited from the build stage; https://stackoverflow.com/a/56748289/339144
ARG WHEEL_FILE
ENV PYTHONUNBUFFERED=1
ENV PORT=8000
WORKDIR /app
# mysqlclient dependencies; needed here too, because the built wheel depends on .o files
RUN apt update && apt install default-libmysqlclient-dev -y
COPY --from=build /wheels /wheels
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
pip install --find-links /wheels --no-index /wheels/$WHEEL_FILE mysqlclient
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
pip install "psycopg[binary]"
COPY bugsink/conf_templates/docker.py.template bugsink_conf.py
RUN ["bugsink-manage", "migrate", "snappea", "--database=snappea"]
CMD [ "monofy", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "bugsink-manage", "migrate", "&&", "bugsink-manage", "prestart", "&&", "gunicorn", "--bind=0.0.0.0:$PORT", "--workers=10", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]