diff --git a/README.md b/README.md index 4b29384..68c5221 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,38 @@ 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.11, you might want to test the next pre-release using + +```yaml +functions: + pgfn: + lang: python3-http-debian + handler: ./pgfn + image: pgfn:latest + build_args: + - PYTHON_VERSION=3.12 +``` +Or pin to a older version while you wait for your dependencies to be updated. + +```yaml +functions: + pgfn: + lang: python3-http-debian + handler: ./pgfn + image: pgfn:latest + build_args: + - PYTHON_VERSION=3.10 +``` + +This can also be set using the `--build-arg` flag. + +```bash +faas-cli build --build-arg PYTHON_VERSION=3.12 +``` + ## 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 caa5824..744f19b 100644 --- a/template/python3-flask-debian/Dockerfile +++ b/template/python3-flask-debian/Dockerfile @@ -1,5 +1,6 @@ +ARG PYTHON_VERSION=3.11 FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-slim-buster as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-slim-buster as build COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog diff --git a/template/python3-flask/Dockerfile b/template/python3-flask/Dockerfile index 1cd2a3a..de91009 100644 --- a/template/python3-flask/Dockerfile +++ b/template/python3-flask/Dockerfile @@ -1,5 +1,6 @@ +ARG PYTHON_VERSION=3.11 FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-alpine as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine as build COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog diff --git a/template/python3-http-debian/Dockerfile b/template/python3-http-debian/Dockerfile index 3ee5153..100050e 100644 --- a/template/python3-http-debian/Dockerfile +++ b/template/python3-http-debian/Dockerfile @@ -1,5 +1,6 @@ +ARG PYTHON_VERSION=3.11 FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-slim-buster as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-slim-buster as build COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog diff --git a/template/python3-http/Dockerfile b/template/python3-http/Dockerfile index 18a2511..6fe7145 100644 --- a/template/python3-http/Dockerfile +++ b/template/python3-http/Dockerfile @@ -1,5 +1,6 @@ +ARG PYTHON_VERSION=3.11 FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog -FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-alpine as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine as build COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog