mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Our goal with having Docker in the first place is to make it easy to deploy the application. 'just migrating' is a good idea for that goal in general, but the more so because running migration commands when the container isn't running yet, while the container refuses to run without them having run putch you in a catch-22. (the above may not be strictly true when you run with a database that's external to your image, i.e. with mysql, because then you can use 'run' rather than 'exec', but even that feels a bit 'wrongish', because run starts a container that is then left around for `docker ps -a` to see) for sqlite containers it's even more pressing, because the writes-to-db go to different databases for each of the incantations of run (including server-start). Even if I get this to work (I can't find the solution in 15 minutes) it will be so clunky to be unworkable. Theoretical concerns about not migrating on-server-start (but rather, as part of some CI/CD script or something) will have take take a back-seat to the reasoning above... if they even hold up at all).
36 lines
1.2 KiB
Docker
36 lines
1.2 KiB
Docker
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
|
|
|
|
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
|
|
|
|
COPY bugsink/conf_templates/docker.py.template bugsink_conf.py
|
|
|
|
RUN ["bugsink-manage", "migrate", "snappea", "--database=snappea"]
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD [ "monofy", "bugsink-manage", "migrate", "&&", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "gunicorn", "--bind=0.0.0.0:8000", "--workers=10", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]
|