-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
108 lines (96 loc) · 3.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
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
FROM quay.io/fedora/python-313:20250108@sha256:214d28a932504676e4c148ab20f866d93114337f2384741561e7c5070231422f AS builder
# builder should use root to install/create all files
USER root
# hadolint ignore=DL3033,DL3041,DL4006,SC2039,SC3040
RUN set -exo pipefail \
&& mkdir -p /mnt/rootfs \
# install runtime dependencies
&& dnf install -y \
--installroot=/mnt/rootfs \
--use-host-config \
--setopt install_weak_deps=false \
--nodocs \
--disablerepo=* \
--enablerepo=fedora,updates \
krb5-libs \
openldap \
python3 \
&& dnf --installroot=/mnt/rootfs clean all \
# https://python-poetry.org/docs/master/#installing-with-the-official-installer
&& curl -sSL --proto "=https" https://install.python-poetry.org | python3 - \
&& python3 -m venv /venv
ENV \
PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
WORKDIR /build
# Copy only specific files to avoid accidentally including any generated files
# or secrets.
COPY product_listings_manager ./product_listings_manager
COPY \
pyproject.toml \
poetry.lock \
README.rst \
docker/docker-entrypoint.sh \
docker/logging.ini \
./
# hadolint ignore=SC1091
RUN set -ex \
&& export PATH=/root/.local/bin:"$PATH" \
&& . /venv/bin/activate \
&& poetry build --format=wheel \
&& version=$(poetry version --short) \
&& pip install --no-cache-dir dist/product_listings_manager-"$version"-py3*.whl \
&& deactivate \
&& mv /venv /mnt/rootfs \
&& mkdir -p /mnt/rootfs/src/docker \
&& cp -v docker-entrypoint.sh /mnt/rootfs/src/docker \
&& cp -v logging.ini /mnt/rootfs/src/docker
# This is just to satisfy linters
USER 1001
# --- Final image
FROM scratch
ARG GITHUB_SHA
ARG EXPIRES_AFTER
LABEL \
name="product-listings-manager" \
vendor="product-listings-manager developers" \
summary="Product Listings Manager application" \
description="HTTP API for finding product listings and interacting with data in composedb." \
maintainer="Red Hat, Inc." \
license="MIT" \
url="https://github.com/release-engineering/product-listings-manager" \
vcs-type="git" \
vcs-ref=$GITHUB_SHA \
io.k8s.display-name="Product Listings Manager" \
quay.expires-after=$EXPIRES_AFTER
ENV \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1 \
WEB_CONCURRENCY=8
COPY --from=builder /mnt/rootfs/ /
COPY --from=builder \
/etc/yum.repos.d/fedora.repo \
/etc/yum.repos.d/fedora-updates.repo \
/etc/yum.repos.d/
WORKDIR /src
USER 1001
EXPOSE 8080
# Validate virtual environment
RUN /src/docker/docker-entrypoint.sh gunicorn --version \
&& /src/docker/docker-entrypoint.sh python -c \
'from product_listings_manager import __version__; print(__version__)'
ENTRYPOINT ["/src/docker/docker-entrypoint.sh"]
CMD [ \
"gunicorn", \
"--bind=0.0.0.0:5000", \
"--access-logfile=-", \
"--enable-stdio-inheritance", \
"--worker-class=uvicorn.workers.UvicornWorker", \
"--log-config=/src/docker/logging.ini", \
"product_listings_manager.wsgi" \
]