forked from jkenlooper/piecemaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
127 lines (113 loc) · 3.31 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# syntax=docker/dockerfile:1.4.3
# Modified from the original in python-worker directory in https://github.com/jkenlooper/cookiecutters .
# UPKEEP due: "2023-04-21" label: "Alpine Linux base image" interval: "+3 months"
# docker pull alpine:3.17.1
# docker image ls --digests alpine
FROM alpine:3.17.1@sha256:f271e74b17ced29b915d351685fd4644785c6d1559dd1f2d4189a5e851ef753a
RUN <<DEV_USER
addgroup -g 44444 dev
adduser -u 44444 -G dev -s /bin/sh -D dev
DEV_USER
WORKDIR /home/dev/app
RUN <<PACKAGE_DEPENDENCIES
# apk add package dependencies
set -o errexit
apk update
apk add --no-cache \
-q --no-progress \
build-base \
freetype \
freetype-dev \
fribidi \
fribidi-dev \
gcc \
harfbuzz \
harfbuzz-dev \
jpeg \
jpeg-dev \
lcms2 \
lcms2-dev \
libffi-dev \
libjpeg \
musl-dev \
openjpeg \
openjpeg-dev \
py3-pip \
python3 \
python3-dev \
tcl \
tcl-dev \
tiff \
tiff-dev \
tk \
tk-dev \
zlib \
zlib-dev
apk add --no-cache \
optipng \
potrace \
rsvg-convert
PACKAGE_DEPENDENCIES
RUN <<PYTHON_VIRTUALENV
# Setup for python virtual env
set -o errexit
mkdir -p /home/dev/app
chown -R dev:dev /home/dev/app
su dev -c '/usr/bin/python3 -m venv /home/dev/app/.venv'
PYTHON_VIRTUALENV
# Activate python virtual env by updating the PATH
ENV VIRTUAL_ENV=/home/dev/app/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --chown=dev:dev pip-requirements.txt /home/dev/app/pip-requirements.txt
COPY --chown=dev:dev dep /home/dev/app/dep
USER dev
RUN <<PIP_INSTALL
# Install pip-requirements.txt
set -o errexit
# Install these first so packages like PyYAML don't have errors with 'bdist_wheel'
python -m pip install wheel
python -m pip install pip
python -m pip install hatchling
python -m pip install \
--no-index \
--no-build-isolation \
--find-links /home/dev/app/dep/ \
-r /home/dev/app/pip-requirements.txt
PIP_INSTALL
COPY --chown=dev:dev requirements.txt /home/dev/app/requirements.txt
COPY --chown=dev:dev requirements-dev.txt /home/dev/app/requirements-dev.txt
COPY --chown=dev:dev requirements-test.txt /home/dev/app/requirements-test.txt
COPY --chown=dev:dev pyproject.toml /home/dev/app/pyproject.toml
COPY --chown=dev:dev src/piecemaker/_version.py /home/dev/app/src/piecemaker/_version.py
COPY --chown=dev:dev README.md /home/dev/app/README.md
RUN <<PIP_INSTALL_APP
# Install the local python packages.
set -o errexit
# Only pip install with the local python packages cache.
python -m pip install --disable-pip-version-check --compile \
--no-index \
--no-build-isolation \
-r /home/dev/app/requirements.txt
python -m pip install --disable-pip-version-check --compile \
--no-index \
--no-build-isolation \
-r /home/dev/app/requirements-dev.txt
python -m pip install --disable-pip-version-check --compile \
--no-index \
--no-build-isolation \
-r /home/dev/app/requirements-test.txt
PIP_INSTALL_APP
COPY --chown=dev:dev src /home/dev/app/src
RUN <<PIP_INSTALL_SRC
# Install app source code in editable mode (-e) for local development.
set -o errexit
python -m pip install --disable-pip-version-check --compile \
--no-index \
--no-build-isolation \
-e /home/dev/app
mkdir -p /home/dev/app/output
PIP_INSTALL_SRC
ENTRYPOINT ["piecemaker"]
# For development the app is installed in 'edit' mode. This requires that the
# script start this way.
#CMD ["python /home/dev/app/src/piecemaker/script.py"]