Skip to content

Commit a8fb1b2

Browse files
LucasRoesleralexellis
authored andcommitted
feat: update python to 3.11 and add build-arg
Update the default python 3 version to 3.11. Additionally, add a build arg for PYTHON_VERSION and WATCHDOG_VERSION so make it easy for developers to pin the python version that they need for their project. The docs are updated with instructions about pinning the python version. Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
1 parent d6080b6 commit a8fb1b2

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,38 @@ The `witness` HTTP server is used along with Flask for all templates.
3232

3333
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`.
3434

35+
## Python Versioning
36+
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.
37+
38+
The current stable version of python is 3.11, you might want to test the next pre-release using
39+
40+
```yaml
41+
functions:
42+
pgfn:
43+
lang: python3-http-debian
44+
handler: ./pgfn
45+
image: pgfn:latest
46+
build_args:
47+
- PYTHON_VERSION=3.12
48+
```
49+
Or pin to a older version while you wait for your dependencies to be updated.
50+
51+
```yaml
52+
functions:
53+
pgfn:
54+
lang: python3-http-debian
55+
handler: ./pgfn
56+
image: pgfn:latest
57+
build_args:
58+
- PYTHON_VERSION=3.10
59+
```
60+
61+
This can also be set using the `--build-arg` flag.
62+
63+
```bash
64+
faas-cli build --build-arg PYTHON_VERSION=3.12
65+
```
66+
3567
## Downloading the templates
3668

3769
Using template pull with the repository's URL:

template/python3-flask-debian/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
2-
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-slim-buster as build
1+
ARG PYTHON_VERSION=3.11
2+
ARG WATCHDOG_VERSION=0.9.10
3+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:${WATCHDOG_VERSION} as watchdog
4+
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-slim-buster as build
35

46
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
57
RUN chmod +x /usr/bin/fwatchdog

template/python3-flask/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
2-
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-alpine as build
1+
ARG PYTHON_VERSION=3.11
2+
ARG WATCHDOG_VERSION=0.9.10
3+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:${WATCHDOG_VERSION} as watchdog
4+
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine as build
35

46
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
57
RUN chmod +x /usr/bin/fwatchdog

template/python3-http-debian/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
2-
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-slim-buster as build
1+
ARG PYTHON_VERSION=3.11
2+
ARG WATCHDOG_VERSION=0.9.10
3+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:${WATCHDOG_VERSION} as watchdog
4+
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-slim-buster as build
35

46
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
57
RUN chmod +x /usr/bin/fwatchdog

template/python3-http/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog
2-
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7-alpine as build
1+
ARG PYTHON_VERSION=3.11
2+
ARG WATCHDOG_VERSION=0.9.10
3+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:${WATCHDOG_VERSION} as watchdog
4+
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine as build
35

46
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
57
RUN chmod +x /usr/bin/fwatchdog

0 commit comments

Comments
 (0)