-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
43 lines (37 loc) · 1.18 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
# BASE
FROM python:3.12-slim AS build
ENV PIP_DEFAULT_TIMEOUT=100 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.8.4
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN pip install "poetry==$POETRY_VERSION" \
&& poetry config warnings.export false \
&& poetry install --no-root --no-ansi --no-interaction \
&& poetry export -f requirements.txt -o requirements.txt
# PROD
FROM python:3.12-slim AS prod
WORKDIR /app
COPY . /app/
COPY --from=build /app/requirements.txt .
RUN set -ex \
&& if id -u 1000 >/dev/null 2>&1; then \
userdel -r "$(id -nu 1000)"; \
fi \
&& if getent group 1000 >/dev/null 2>&1; then \
groupdel "$(getent group 1000 | cut -d: -f1)"; \
fi \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends procps \
&& pip install -r requirements.txt \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& find /usr/local/lib/python3.12 -name '__pycache__' -exec rm -r {} + \
&& find /usr/local/lib/python3.12 -name '*.pyc' -delete
EXPOSE 5454
CMD ["sh", "./run.sh"]
USER root