-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
43 lines (29 loc) · 1.1 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
FROM python:3.9-slim as base
RUN apt-get update && apt-get install -y --no-install-recommends -qq gcc=4:10.2.1-1 libffi-dev=3.3-6 g++=4:10.2.1-1 git=1:2.30.2-1 curl=7.74.0-1.3+deb11u1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
FROM base as builder
ENV POETRY_VERSION=1.1.13
RUN pip install --no-cache-dir poetry==$POETRY_VERSION
COPY pyproject.toml poetry.lock ./
RUN python -m venv --copies /venv
RUN . /venv/bin/activate && poetry install --no-dev --no-root
FROM base as production
COPY --from=builder /venv /venv
COPY . .
RUN mkdir -p /var/www && chown www-data /var/www && \
apt-get clean && find /var/lib/apt/lists/ -type f -delete && \
chown -R www-data /app/ && chown -R www-data /venv
ENV PYTHONPATH="/venv/lib/python3.9/site-packages/"
ENV PATH=$PATH:/venv/bin
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PROMETHEUS_PORT 9000
ENV PULSE_SERVER_PORT 9010
EXPOSE $PROMETHEUS_PORT
USER www-data
HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -f http://localhost:$PULSE_SERVER_PORT/healthcheck || exit 1
ENTRYPOINT ["python3"]
CMD ["-m", "myproject.main"]