-
Notifications
You must be signed in to change notification settings - Fork 148
/
Dockerfile.prod
48 lines (39 loc) · 1.28 KB
/
Dockerfile.prod
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
FROM python:3.12-bullseye
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=utf-8 \
# pip
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=100 \
PIP_ROOT_USER_ACTION=ignore \
# poetry
POETRY_VERSION=1.8.3 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr/local' \
# app
PROMETHEUS_MULTIPROC_DIR=/tmp/prometheus_multiproc_dir
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
RUN apt-get update && \
apt-get install -y gcc libpq-dev curl && \
curl -sSL 'https://install.python-poetry.org' | python - \
&& poetry --version \
apt clean && \
rm -rf /var/cache/apt/*
COPY poetry.lock pyproject.toml /src/
WORKDIR /src
RUN --mount=type=cache,target="$POETRY_CACHE_DIR" \
echo "$ENVIRONMENT" \
# Install deps:
&& poetry run pip install -U pip \
&& poetry install \
--no-interaction --no-ansi --sync --with prod
COPY . .
RUN useradd -m -d /src -s /bin/bash app \
&& chown -R app:app /src/* && chown -R app:app /src \
&& chmod +x entrypoints/* \
&& rm -rf /tmp/prometheus_multiproc_dir && mkdir -p /tmp/prometheus_multiproc_dir \
&& chown -R app:app /tmp/prometheus_multiproc_dir
USER app