Skip to content

Commit c2eb9d4

Browse files
committed
Update packages in docker image; supress pip warning; improve cache
use apk to update packages in image to get security fixes pip warns when run as root. In a dcker environment this can be ignored as the entire image is effectively a venv. Move inclusion of specific pip packages lower in the build procedure so we can cache all prior layers. Including it earlier resulted in layers that could be cached being invalidated.
1 parent fedce5e commit c2eb9d4

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

scripts/Docker/Dockerfile

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ ARG appdir
2525

2626
WORKDIR $appdir
2727

28+
# Update to get security and other improvements;
29+
RUN apk --update-cache upgrade
30+
2831
# Add packages needed to compile mysql, pgsql and other python modules.
2932
# Can't use apk to add them as that installs a 3.9 python version.
3033
# g++ installs cc1plus needed by pip install
@@ -46,6 +49,9 @@ RUN apk add \
4649
# they are over 70MB of space.
4750
COPY scripts/Docker/sphinxdeps.txt .
4851

52+
# suppress warning when running pip as root
53+
ENV PIP_ROOT_USER_ACTION=ignore
54+
4955
RUN set -xv && CWD=$PWD && \
5056
VER=$(apk list -I 'xapian-core-dev' | \
5157
sed 's/^xapian-core-dev-\([0-9.]*\)-.*/\1/') && \
@@ -65,10 +71,6 @@ RUN set -xv && CWD=$PWD && \
6571
COPY scripts/Docker/requirements.txt .
6672
RUN pip install --no-cache-dir -r requirements.txt
6773

68-
# Allow user to add more modules during build
69-
ARG pip_mod
70-
RUN if [ -n "$pip_mod" ]; then pip install --no-cache-dir ${pip_mod}; fi
71-
7274
# copy the elements of the release directory to the docker image
7375
COPY setup.py install/
7476
COPY doc install/doc/
@@ -94,6 +96,10 @@ RUN set -xv && if [ "$source" = "local" ] || \
9496
cp -ril /usr/local/lib/python3.10/site-packages/usr/local/share/* \
9597
/usr/local/share; fi
9698

99+
# Allow user to add more modules during build
100+
ARG pip_mod
101+
RUN if [ -n "$pip_mod" ]; then pip install --no-cache-dir ${pip_mod}; fi
102+
97103
# build a new smaller docker image for execution. Build image above
98104
# is 1G in size.
99105
FROM python:3-alpine
@@ -103,18 +109,28 @@ ARG appdir
103109

104110
WORKDIR $appdir
105111

112+
# suppress warning when running pip as root
113+
ENV PIP_ROOT_USER_ACTION=ignore
114+
115+
# upgrade to get any security updates; bundle with
116+
# rest of apk actions to reduce layers/wasted space
106117
# add libraries needed to run gpg/mysql/pgsql/brotli
107-
RUN apk add \
118+
# clean out any caches to save space
119+
RUN apk --update-cache upgrade; \
120+
apk add \
121+
brotli-libs \
108122
gpgme \
109123
mariadb-connector-c \
110124
libpq \
111125
libstdc++ \
112-
libxapian
126+
libxapian \
127+
zstd-libs; \
128+
rm -f /var/cache/apk/*
113129

114130
ARG source
115131
LABEL "org.roundup-tracker.vendor"="Roundup Issue Tracker Team" \
116-
"org.roundup-tracker.description"="Roundup Issue Tracker using sqlite" \
117-
"version"="2.1.0 $source" \
132+
"org.roundup-tracker.description"="Roundup Issue Tracker multi-backend" \
133+
"version"="2.2.0 $source" \
118134
"org.opencontainers.image.authors"="[email protected]"
119135

120136

0 commit comments

Comments
 (0)