-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Dockerfile.local
80 lines (65 loc) · 2.17 KB
/
Dockerfile.local
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
FROM python:3.13-alpine AS builder
RUN apk add --no-cache --update --virtual .build-deps \
build-base \
linux-headers \
ca-certificates \
python3-dev \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk \
&& ln -sf /lib/ld-musl-x86_64.so.1 /usr/bin/ldd \
&& ln -s /lib /lib64
WORKDIR /svc
ARG VERSION=1
RUN echo "Version: ${VERSION}"
COPY . ./
ARG FLASK_ASYNC=0 \
MYPYC_ENABLE=0
RUN pip install pip wheel --upgrade \
&& echo "Flask Async? ${FLASK_ASYNC}" \
&& echo "Mypyc compile? ${MYPYC_ENABLE}" \
&& [[ ${FLASK_ASYNC} = 1 ]] \
&& PROJECT_PATH=".[async]" \
|| PROJECT_PATH="." \
&& [[ ${MYPYC_ENABLE} = 1 ]] \
&& python -m pip install -r requirements/base.txt -r requirements/cbuild.txt \
&& pip wheel --wheel-dir=/svc/wheels -e ${PROJECT_PATH} \
&& python setup.py bdist_wheel --dist-dir /svc/dist \
|| pip wheel --wheel-dir=/svc/wheels -e ${PROJECT_PATH}
FROM python:3.13-alpine
ENV PYTHONUNBUFFERED=1 \
DEBUG=0 \
FLASK_SERVER_NAME="app:5000"
RUN apk add --no-cache --update \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk \
&& ln -sf /lib/ld-musl-x86_64.so.1 /usr/bin/ldd \
&& ln -s /lib /lib64 \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
WORKDIR /svc
COPY --from=builder /svc /svc
WORKDIR /app
ARG FLASK_ASYNC=0 \
MYPYC_ENABLE=0
RUN pip install pip setuptools wheel --upgrade \
&& echo "Flask Async? ${FLASK_ASYNC}" \
&& [[ ${FLASK_ASYNC} = 1 ]] \
&& PIP_INSTALL_PACKAGES="Flask-JSONRPC[async]" \
|| PIP_INSTALL_PACKAGES="Flask-JSONRPC" \
&& pip install --no-index --find-links=/svc/wheels ${PIP_INSTALL_PACKAGES} \
&& [[ ${MYPYC_ENABLE} = 1 ]] \
&& pip install /svc/dist/* --force-reinstall \
|| echo "Do nothing..." \
&& addgroup -S flask_user \
&& adduser \
--disabled-password \
--gecos "" \
--ingroup flask_user \
--no-create-home \
-s /bin/false \
flask_user \
&& chown flask_user:flask_user -R /app
USER flask_user
ARG VERSION=1
RUN echo "Version: ${VERSION}"
COPY .docker/* tests/test_apps/ /app/