-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
88 lines (67 loc) · 1.83 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
ARG PYTHON_VERSION=3.12-slim-bookworm
ARG SOURCE_DIR=src
ARG APP_PATH=/opt/app
ARG APP_USER=watchtower
FROM python:${PYTHON_VERSION} AS builder-base
SHELL ["/bin/bash", "-exc"]
RUN apt-get update -qy \
&& apt-get install --no-install-recommends --no-install-suggests -qyy \
# deps for building python deps
build-essential \
# pytezos deps
libsodium-dev libgmp-dev pkg-config \
\
# cleanup \
&& apt-get clean \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/* \
&& rm -rf /root/.cache \
&& rm -rf /var/lib/apt/lists/*
FROM builder-base AS builder-production
ARG APP_PATH
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=0 \
UV_PYTHON_DOWNLOADS=never \
UV_PROJECT_ENVIRONMENT=$APP_PATH
COPY ["uv.lock", "pyproject.toml", "/lock/"]
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
cd /lock/ && \
uv sync --locked --no-install-project --no-dev --no-cache && \
cd $APP_PATH/lib/python3.12/site-packages && rm -rf \
nbclassic \
debugpy \
cytoolz \
pygments \
jedi \
IPython \
pyzmq.libs \
notebook \
jupyter_server \
tornado \
prompt_toolkit
FROM python:${PYTHON_VERSION} AS runtime-base
SHELL ["/bin/bash", "-exc"]
RUN apt-get update -qy \
&& apt-get install --no-install-recommends --no-install-suggests -qyy \
# pytezos deps
libsodium-dev libgmp-dev pkg-config \
\
# cleanup \
&& apt-get clean \
&& rm -rf /tmp/* \
&& rm -rf /var/tmp/* \
&& rm -rf /root/.cache \
&& rm -rf /var/lib/apt/lists/*
ARG APP_PATH
ENV PATH=$APP_PATH/bin:$PATH
WORKDIR $APP_PATH
ARG APP_USER
RUN useradd -ms /bin/bash $APP_USER
FROM runtime-base AS runtime
ARG APP_PATH
COPY --from=builder-production --chown=$APP_USER ["$APP_PATH", "$APP_PATH"]
ARG APP_USER
USER $APP_USER
ARG SOURCE_DIR
COPY --chown=$APP_USER $SOURCE_DIR/* .
CMD ["python", "-u", "app.py"]