35 lines
1.3 KiB
Docker
35 lines
1.3 KiB
Docker
# The image is the runtime only: Python, git and the scripts in this folder. The app's
|
|
# source is cloned into the /srv volume on first start and updated in place by `update`,
|
|
# so a rebuild is needed only when this folder or the Python version changes.
|
|
ARG PYTHON_VERSION=__PYTHON__
|
|
FROM python:${PYTHON_VERSION}-slim
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends git openssh-client tini \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ARG UID=1000
|
|
ARG GID=1000
|
|
RUN groupadd --gid "$GID" app \
|
|
&& useradd --uid "$UID" --gid app --create-home --shell /usr/sbin/nologin app \
|
|
&& mkdir -p /srv/src /srv/venv /srv/state /data \
|
|
&& chown -R app:app /srv /data \
|
|
&& git config --system --add safe.directory '*'
|
|
|
|
COPY container/lib.sh /usr/local/lib/app/lib.sh
|
|
COPY --chmod=755 container/entrypoint.sh /usr/local/bin/entrypoint
|
|
COPY --chmod=755 container/update.sh /usr/local/bin/update
|
|
|
|
ENV PATH=/srv/venv/bin:$PATH \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
DATA_DIR=/data \
|
|
PORT=8000
|
|
|
|
USER app
|
|
WORKDIR /srv/src
|
|
EXPOSE 8000
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
|
CMD python3 -c "import os, urllib.request; urllib.request.urlopen(f'http://127.0.0.1:{os.environ[\"PORT\"]}/healthz', timeout=3)"
|
|
ENTRYPOINT ["tini", "--", "entrypoint"]
|