-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
125 lines (115 loc) · 3.89 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
FROM registry.fedoraproject.org/fedora:39 as builder
# hadolint ignore=DL3033,DL4006,SC2039,SC3040
RUN set -exo pipefail \
&& mkdir -p /mnt/rootfs \
# install builder dependencies
&& yum install -y \
--setopt install_weak_deps=false \
--nodocs \
--disablerepo=* \
--enablerepo=fedora,updates \
gcc \
krb5-devel \
openldap-devel \
python3 \
python3-devel \
httpd-devel \
# install runtime dependencies
&& yum install -y \
--installroot=/mnt/rootfs \
--releasever=/ \
--setopt install_weak_deps=false \
--nodocs \
--disablerepo=* \
--enablerepo=fedora,updates \
krb5-libs \
mod_ssl \
openldap \
python3 \
httpd-core \
&& yum --installroot=/mnt/rootfs clean all \
&& rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.* \
# https://python-poetry.org/docs/master/#installing-with-the-official-installer
&& curl -sSL --proto "=https" https://install.python-poetry.org | python3 - \
&& python3 -m venv --system-site-packages /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 resultsdb ./resultsdb
COPY conf ./conf
COPY \
pyproject.toml \
poetry.lock \
README.md \
alembic.ini \
entrypoint.sh \
./
# 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/resultsdb-"$version"-py3*.whl \
&& deactivate \
&& mv /venv /mnt/rootfs \
&& mkdir -p /mnt/rootfs/app \
&& cp -v entrypoint.sh /mnt/rootfs/app
# fix apache config for container use
RUN sed -i 's#^WSGISocketPrefix .*#WSGISocketPrefix /tmp/wsgi#' conf/resultsdb.conf \
# install configuration
&& install -d /mnt/rootfs/usr/share/resultsdb/conf \
&& install -p -m 0644 conf/resultsdb.conf /mnt/rootfs/usr/share/resultsdb/conf/ \
&& install -p -m 0644 conf/resultsdb.wsgi /mnt/rootfs/usr/share/resultsdb/ \
&& install -d /mnt/rootfs/etc/resultsdb \
&& install -p -m 0644 conf/resultsdb.conf /mnt/rootfs/etc/httpd/conf.d/ \
# install alembic configuration and migrations
&& install -p -m 0644 alembic.ini /mnt/rootfs/usr/share/resultsdb/alembic.ini \
&& cp -a resultsdb/alembic /mnt/rootfs/usr/share/resultsdb/alembic \
&& chmod -R 0755 /mnt/rootfs/usr/share/resultsdb/alembic
# --- Final image
FROM scratch
ARG GITHUB_SHA
ARG EXPIRES_AFTER
LABEL \
name="ResultsDB application" \
vendor="ResultsDB developers" \
license="GPLv2+" \
description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
usage="https://pagure.io/taskotron/resultsdb/blob/develop/f/openshift/README.md" \
url="https://github.com/release-engineering/resultsdb" \
vcs-type="git" \
vcs-ref=$GITHUB_SHA \
io.k8s.display-name="ResultsDB" \
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 /app
USER 1001
EXPOSE 5001
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["mod_wsgi-express", "start-server", "/usr/share/resultsdb/resultsdb.wsgi", \
"--user", "apache", "--group", "apache", \
"--port", "5001", "--threads", "5", \
"--include-file", "/etc/httpd/conf.d/resultsdb.conf", \
"--log-level", "info", \
"--log-to-terminal", \
"--access-log", \
"--startup-log" \
]
USER 1001:0