From d78fec93685be0a28b294c461f2a0dfa4d5bf4c4 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Tue, 16 Jul 2024 11:50:25 +0100 Subject: [PATCH] Update Debian OS version for newer Python version Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- README.md | 3 +++ template/python3-flask-debian/Dockerfile | 5 +++-- template/python3-http-debian/Dockerfile | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7e2f3fe..fb8e96a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The `witness` HTTP server is used along with Flask for all templates. Are you referencing pip modules which require a native build toolchain? It's advisable to use the template with a `-debian` suffix in this case. The Debian images are larger, however they are usually more efficient for use with modules like `numpy` and `pandas`. ## Python Versioning + We try to keep the default Python 3 version up-to-date, however, you can specify a specific python version using the `PYTHON_VERSION` build argument. The current stable version of Python is 3.12, you might want to test the next pre-release using: @@ -64,6 +65,8 @@ This can also be set using the `--build-arg` flag. faas-cli build --build-arg PYTHON_VERSION=3.12 ``` +For the `-debian` templates, the `DEBIAN_OS` build_args is also available to specify the Debian version. The default is currently `bookworm`. + ## Downloading the templates Using template pull with the repository's URL: diff --git a/template/python3-flask-debian/Dockerfile b/template/python3-flask-debian/Dockerfile index 9c685cb..e892432 100644 --- a/template/python3-flask-debian/Dockerfile +++ b/template/python3-flask-debian/Dockerfile @@ -1,6 +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}-slim-buster AS build +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-${DEBIAN_OS} AS build COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog @@ -14,7 +15,7 @@ RUN apt-get -qy update \ # Add non root user RUN addgroup --system app && adduser app --system --ingroup app -RUN chown app /home/app +RUN mkdir -p /home/app && chown app /home/app USER app diff --git a/template/python3-http-debian/Dockerfile b/template/python3-http-debian/Dockerfile index 73bdb54..af05c8f 100644 --- a/template/python3-http-debian/Dockerfile +++ b/template/python3-http-debian/Dockerfile @@ -1,6 +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}-slim-buster AS build +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-${DEBIAN_OS} AS build COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog @@ -14,7 +15,7 @@ RUN apt-get -qy update \ # Add non root user RUN addgroup --system app && adduser app --system --ingroup app -RUN chown app /home/app +RUN mkdir -p /home/app && chown app /home/app USER app