forked from bugsink/bugsink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (53 loc) · 2.95 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (53 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# This is the Dockerfile that builds an image form the current directory.
# It is provided as-is; the Bugsink team does not use this in their own
# development. Tips:
# * Configure your database/filestore/etc _outside_ of the current path
# to avoid copying them into the image.
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=/root/.cache/pip \
pip wheel --wheel-dir /wheels mysqlclient
# Actual image (based on slim)
FROM python:${PYTHON_VERSION}-slim
ENV PYTHONUNBUFFERED=1
ENV PORT=8000
WORKDIR /app
# Runtime shared library the mysqlclient wheel links against.
RUN apt update && apt install libmariadb3 -y \
&& rm -rf /var/lib/apt/lists/*
# Install all deps and strip native extensions in a single layer, so only the
# stripped binaries are stored (must be same layer to actually shrink the image).
# binutils is installed and purged here; requirements/wheels are bind-mounted,
# not COPYed, so they don't end up in a layer.
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,from=build,source=/wheels,target=/wheels \
--mount=type=bind,source=requirements.txt,target=/tmp/requirements.txt \
apt-get update \
&& apt-get install -y --no-install-recommends binutils \
&& pip install --find-links /wheels --no-index mysqlclient \
&& pip install "psycopg[binary]" \
&& pip install -r /tmp/requirements.txt \
&& find /usr/local/lib/python3.12/site-packages -name '*.so' -exec strip --strip-unneeded {} + \
&& apt-get purge -y binutils && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
COPY . /app/
COPY bugsink/conf_templates/docker.py.template bugsink_conf.py
# git is only needed by setuptools_scm during the editable install; install and
# purge it in the same layer so it stays out of the final image.
RUN --mount=type=cache,target=/root/.cache/pip \
apt-get update \
&& apt-get install -y --no-install-recommends git \
&& pip install -e . \
&& apt-get purge -y git && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd --gid 14237 bugsink \
&& useradd --uid 14237 --gid 14237 bugsink \
&& mkdir -p /data \
&& chown -R bugsink:bugsink /data
USER bugsink
HEALTHCHECK CMD python -c 'import requests; requests.get("http://localhost:8000/health/ready").raise_for_status()'
CMD [ "monofy", "bugsink-show-version", "&&", "bugsink-manage", "check", "--deploy", "--fail-level", "WARNING", "&&", "bugsink-manage", "migrate", "snappea", "--database=snappea", "&&", "bugsink-manage", "migrate", "&&", "bugsink-manage", "prestart", "&&", "gunicorn", "--config", "bugsink/gunicorn.docker.conf.py", "--bind=0.0.0.0:$PORT", "--access-logfile", "-", "bugsink.wsgi", "|||", "bugsink-runsnappea"]