Skip to content

Commit

Permalink
Add UPGRADE_PACKAGES for Debian-based templates
Browse files Browse the repository at this point in the history
The UPGRADE_PACKAGES build_arg will invoke an apt upgrade to
help with warnings generated from CVE / image scanners.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Aug 8, 2024
1 parent 919525e commit 6963576
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions template/python3-flask-debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ARG PYTHON_VERSION=3.12
ARG DEBIAN_OS=slim-bookworm
ARG UPGRADE_PACKAGES=false

FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 AS watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-${DEBIAN_OS} AS build

Expand All @@ -9,8 +11,9 @@ RUN chmod +x /usr/bin/fwatchdog
ARG ADDITIONAL_PACKAGE
# Alternatively use ADD https:// (which will not be cached by Docker builder)

RUN apt-get -qy update \
&& apt-get -qy install gcc make ${ADDITIONAL_PACKAGE} \
RUN apt-get update -qy \
&& if [ "${UPGRADE_PACKAGES}" = "true" ] || [ "${UPGRADE_PACKAGES}" = "1" ]; then apt-get upgrade -qy; fi \
&& apt-get install -qy --no-install-recommends gcc make ${ADDITIONAL_PACKAGE} \
&& rm -rf /var/lib/apt/lists/*

# Add non root user
Expand Down
8 changes: 6 additions & 2 deletions template/python3-http-debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ARG PYTHON_VERSION=3.12
ARG DEBIAN_OS=slim-bookworm


FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 AS watchdog
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-${DEBIAN_OS} AS build

Expand All @@ -8,9 +10,11 @@ RUN chmod +x /usr/bin/fwatchdog

ARG ADDITIONAL_PACKAGE
# Alternatively use ADD https:// (which will not be cached by Docker builder)
ARG UPGRADE_PACKAGES=false

RUN apt-get -qy update \
&& apt-get -qy install ${ADDITIONAL_PACKAGE} \
RUN apt-get update -qy \
&& if [ "${UPGRADE_PACKAGES}" = "true" ] || [ "${UPGRADE_PACKAGES}" = "1" ]; then apt-get upgrade -qy; fi \
&& apt-get install -qy --no-install-recommends gcc make ${ADDITIONAL_PACKAGE} \
&& rm -rf /var/lib/apt/lists/*

# Add non root user
Expand Down

0 comments on commit 6963576

Please sign in to comment.