mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
My reasoning is twofold: 1. a count of 1 is actually probably "enough for many setups" because ingestion is very fast anyway (just store the file); while the lower memory-footprint that comes with having fewer workers means that adoption of Bugsink will be easier. 2. tuning the variable is going to be less annoying if there's no default that might override "in the wrong direction" (i.e. the interaction between `WEB_CONCURRENCY` and `GUNICORN_CMD_ARGS`) See #101 (where the concept of customizability was discussed, though not the present idea of chaning the default).
80 lines
3.4 KiB
Docker
80 lines
3.4 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
|
|
|
|
# mysqlclient is not available as a .whl on PyPI, so we need to build it from
|
|
# source and store the .whl. This is both the most expensive part of the build
|
|
# and the one that is least likely to change, so we do it first.
|
|
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
|
|
pip wheel --wheel-dir /wheels mysqlclient
|
|
|
|
# NOTE: At some point in the past, we built all requirements as encoded in the
|
|
# Bugsink wheel file into wheels at this point. It is not clear that this saves
|
|
# any build time however, because:
|
|
#
|
|
# * this moves the dependency on the bugsink wheel up in the build-order, and
|
|
# that's precisely the most changing part, i.e. the thing that breaks caching.
|
|
#
|
|
# * all current (Apr 2025) dependencies .whl files are available on PyPI anyway.
|
|
# Exception: inotify_simple, but it's a pure python tar.gz; Nothing much
|
|
# is gained by fetch-first-install-later. And if we ever depend on further
|
|
# packages that require a build step, explicit action is probably needed
|
|
# anyway b/c of the build deps.
|
|
#
|
|
# * pointing to requirements.txt here instead of the wheel is tempting, but
|
|
# breaks the idea of "just build the wheel" (requirements.txt is whatever
|
|
# it happens to be right now, not what it was at the time the wheel was
|
|
# built)
|
|
#
|
|
# Moreover, there's the argument of image _size_ rather than build time, and
|
|
# copying over all wheels instead of just their unpacked equivalents increases
|
|
# that.
|
|
|
|
# Actual image (based on slim)
|
|
FROM python:${PYTHON_VERSION}-slim
|
|
|
|
ARG WHEEL_FILE=wheelfile-not-specified.whoops
|
|
|
|
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 mysqlclient
|
|
|
|
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
|
|
pip install "psycopg[binary]"
|
|
|
|
COPY dist/$WHEEL_FILE /wheels/
|
|
|
|
RUN --mount=type=cache,target=/var/cache/buildkit/pip \
|
|
pip install /wheels/$WHEEL_FILE
|
|
|
|
COPY bugsink/conf_templates/docker.py.template bugsink_conf.py
|
|
|
|
RUN ["bugsink-manage", "migrate", "snappea", "--database=snappea"]
|
|
|
|
HEALTHCHECK CMD python -c 'import requests; requests.get("http://localhost:8000/health/ready").raise_for_status()'
|
|
|
|
CMD [ "monofy", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "bugsink-manage", "migrate", "&&", "bugsink-manage", "prestart", "&&", "gunicorn", "--bind=0.0.0.0:$PORT", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]
|