-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
51 lines (36 loc) · 1.15 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
FROM python:3.12.4-slim as base
RUN apt-get update && apt-get install -y --no-install-recommends -qq \
gcc=4:12.2.0-3 \
libffi-dev=3.4.4-1 \
g++=4:12.2.0-3 \
curl=7.88.1-10+deb12u7 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
VENV_PATH="/.venv"
ENV PATH="$VENV_PATH/bin:$PATH"
FROM base as builder
ENV POETRY_VERSION=1.8.2
RUN pip install --no-cache-dir poetry==$POETRY_VERSION
WORKDIR /
COPY pyproject.toml poetry.lock ./
RUN poetry install --only main --no-root
FROM base as production
COPY --from=builder $VENV_PATH $VENV_PATH
WORKDIR /app
COPY . .
RUN apt-get clean && find /var/lib/apt/lists/ -type f -delete && chown -R www-data /app/
ENV PROMETHEUS_PORT 9000
ENV HEALTHCHECK_SERVER_PORT 9010
EXPOSE $PROMETHEUS_PORT
USER www-data
HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -f http://localhost:$HEALTHCHECK_SERVER_PORT/healthcheck || exit 1
WORKDIR /app/
ENTRYPOINT ["python3", "src/main.py"]