-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (46 loc) · 1.7 KB
/
Dockerfile
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
# syntax=docker/dockerfile:1
FROM python:3.11-slim as python-base
LABEL maintainer="kitconcept GmbH <info@kitconcept.com>" \
org.label-schema.name="cluster-purger" \
org.label-schema.description="Purge multiple instances of Varnish inside a cluster" \
org.label-schema.vendor="kitconcept GmbH" \
org.opencontainers.image.source="https://github.com/kitconcept/cluster-purger"
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Run Poetry without interactions
ENV POETRY_NO_INTERACTION=1
# Install the Poetry virtualenv inside the project
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
# Install wget (to run healthchecks), dnsutils (debugging)
# Install Poetry
# Create appuser
RUN <<EOT
apt-get update
apt-get -y upgrade
apt-get install -y --no-install-recommends dnsutils wget
apt-get clean -y
useradd --system -m -d /app -U -u 500 appuser
chown -R 500:500 /app
python -m pip install poetry
EOT
# Set /app as working directory
WORKDIR /app
# Copy project files to the container
COPY --chown=500:500 cluster_purger /app/cluster_purger
COPY --chown=500:500 pyproject.toml poetry.lock README.md docker-entrypoint.sh /app/
# Install Poetry
RUN <<EOT
poetry install --without test
EOT
# Expose port 80
EXPOSE 80
# User appuser
USER appuser
# prepend poetry and venv to path
ENV PATH="/app/.venv/bin:$PATH"
# Set healthcheck to port 8080
HEALTHCHECK --interval=5s --timeout=5s --start-period=30s CMD [ -n "$LISTEN_PORT" ] || LISTEN_PORT=80 ; wget -q http://127.0.0.1:"$LISTEN_PORT"/ok -O - | grep Ok || exit 1
# Start cluster-purger
CMD ["/app/docker-entrypoint.sh"]