-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
91 lines (80 loc) · 2.58 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
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 \
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 greenwave ./greenwave
COPY conf ./conf
COPY docker ./docker
COPY \
pyproject.toml \
poetry.lock \
README.md \
./
# 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/greenwave-"$version"-py3*.whl \
&& deactivate \
&& mv /venv /mnt/rootfs \
&& mkdir -p /mnt/rootfs/src/docker \
&& cp -v docker/docker-entrypoint.sh /mnt/rootfs/src/docker \
&& cp -vr conf /mnt/rootfs/src
# This is just to satisfy linters
USER 1001
# --- Final image
FROM scratch
ARG GITHUB_SHA
ARG EXPIRES_AFTER
LABEL \
summary="Greenwave application" \
description="Decision-making service for gating in a software delivery pipeline." \
maintainer="Red Hat, Inc." \
license="GPLv2+" \
url="https://github.com/release-engineering/greenwave" \
vcs-type="git" \
vcs-ref=$GITHUB_SHA \
io.k8s.display-name="Greenwave" \
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
ENTRYPOINT ["/src/docker/docker-entrypoint.sh"]
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--access-logfile", "-", "--enable-stdio-inheritance", "greenwave.wsgi:app"]