From d64ee9483b65fb57f57ef410db28eaf2136dfdd0 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Thu, 8 Aug 2024 13:05:16 +0100 Subject: [PATCH] Support UPGRADE_PACKAGES for alpine images Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- template/python3-flask/Dockerfile | 7 +++++-- template/python3-http/Dockerfile | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/template/python3-flask/Dockerfile b/template/python3-flask/Dockerfile index e60eede..932522b 100644 --- a/template/python3-flask/Dockerfile +++ b/template/python3-flask/Dockerfile @@ -5,12 +5,15 @@ FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine A COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +ARG UPGRADE_PACKAGES=false + ARG ADDITIONAL_PACKAGE # Alternatively use ADD https:// (which will not be cached by Docker builder) -RUN apk --no-cache add openssl-dev ${ADDITIONAL_PACKAGE} +RUN if [ "${UPGRADE_PACKAGES}" = "true" ] || [ "${UPGRADE_PACKAGES}" = "1" ]; then apk --no-cache upgrade; fi && \ + apk --no-cache add openssl-dev ${ADDITIONAL_PACKAGE} -# Add non root user + # Add non root user RUN addgroup -S app && adduser app -S -G app RUN chown app /home/app diff --git a/template/python3-http/Dockerfile b/template/python3-http/Dockerfile index 605e86f..837a032 100644 --- a/template/python3-http/Dockerfile +++ b/template/python3-http/Dockerfile @@ -5,10 +5,12 @@ FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine A COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog +ARG UPGRADE_PACKAGES ARG ADDITIONAL_PACKAGE # Alternatively use ADD https:// (which will not be cached by Docker builder) -RUN apk --no-cache add ${ADDITIONAL_PACKAGE} +RUN if [ "${UPGRADE_PACKAGES}" = "true" ] || [ "${UPGRADE_PACKAGES}" = "1" ]; then apk --no-cache upgrade; fi && \ + apk --no-cache add ${ADDITIONAL_PACKAGE} # Add non root user RUN addgroup -S app && adduser app -S -G app