From 2bf8850cd7acf7e8fd8648d3a94be8c891536477 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Tue, 16 Jul 2024 10:09:09 +0100 Subject: [PATCH] Update of-watchdog to 0.10.4 Includes optional X-Timeout header and better streamed responses support, without buffering into memory first. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- template/bun/Dockerfile | 2 +- template/java11-vert-x/Dockerfile | 2 +- template/java11/Dockerfile | 2 +- template/node14/Dockerfile | 2 +- template/node16/Dockerfile | 2 +- template/node17/Dockerfile | 2 +- template/node18/Dockerfile | 2 +- template/node20/Dockerfile | 2 +- template/python3-streaming/Dockerfile | 58 +++++++++++++++++++++++++++ 9 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 template/python3-streaming/Dockerfile diff --git a/template/bun/Dockerfile b/template/bun/Dockerfile index 9afdf551..bace3c11 100644 --- a/template/bun/Dockerfile +++ b/template/bun/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} oven/bun:1.0-alpine as ship ARG TARGETPLATFORM diff --git a/template/java11-vert-x/Dockerfile b/template/java11-vert-x/Dockerfile index 3aad40c5..84a2dfbe 100644 --- a/template/java11-vert-x/Dockerfile +++ b/template/java11-vert-x/Dockerfile @@ -27,7 +27,7 @@ COPY . /home/app/ RUN gradle build -FROM ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM openjdk:11-jre-slim as ship COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog diff --git a/template/java11/Dockerfile b/template/java11/Dockerfile index 78a9435f..6ab96dc1 100644 --- a/template/java11/Dockerfile +++ b/template/java11/Dockerfile @@ -28,7 +28,7 @@ COPY . /home/app/ RUN gradle build RUN find . -FROM ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM openjdk:11-jre-slim as ship RUN apt-get update -qqy \ diff --git a/template/node14/Dockerfile b/template/node14/Dockerfile index 944220e3..9f160b2e 100644 --- a/template/node14/Dockerfile +++ b/template/node14/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} node:14-alpine as ship ARG TARGETPLATFORM diff --git a/template/node16/Dockerfile b/template/node16/Dockerfile index 3373f726..2d5f6bfd 100644 --- a/template/node16/Dockerfile +++ b/template/node16/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} node:16-alpine as ship ARG TARGETPLATFORM diff --git a/template/node17/Dockerfile b/template/node17/Dockerfile index 2c4f721c..44440405 100644 --- a/template/node17/Dockerfile +++ b/template/node17/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} node:17-alpine as ship ARG TARGETPLATFORM diff --git a/template/node18/Dockerfile b/template/node18/Dockerfile index afd401ed..51c86e75 100644 --- a/template/node18/Dockerfile +++ b/template/node18/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} node:18-alpine as ship ARG TARGETPLATFORM diff --git a/template/node20/Dockerfile b/template/node20/Dockerfile index bb847238..678195dd 100644 --- a/template/node20/Dockerfile +++ b/template/node20/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.1 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} node:20-alpine as ship ARG TARGETPLATFORM diff --git a/template/python3-streaming/Dockerfile b/template/python3-streaming/Dockerfile new file mode 100644 index 00000000..79fa3d9b --- /dev/null +++ b/template/python3-streaming/Dockerfile @@ -0,0 +1,58 @@ +ARG PYTHON_VERSION=3 +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.10.4 as watchdog +FROM --platform=${TARGETPLATFORM:-linux/amd64} python:${PYTHON_VERSION}-alpine + +ARG TARGETPLATFORM +ARG BUILDPLATFORM + +# Allows you to add additional packages via build-arg +ARG ADDITIONAL_PACKAGE + +COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog +RUN chmod +x /usr/bin/fwatchdog +RUN apk --no-cache add ca-certificates ${ADDITIONAL_PACKAGE} + + +# Add non root user +RUN addgroup -S app && adduser app -S -G app + +WORKDIR /home/app/ + +COPY index.py . +COPY requirements.txt . + +RUN chown -R app /home/app && \ + mkdir -p /home/app/python && chown -R app /home/app +USER app +ENV PATH=$PATH:/home/app/.local/bin:/home/app/python/bin/ +ENV PYTHONPATH=$PYTHONPATH:/home/app/python + +RUN pip install -r requirements.txt --target=/home/app/python + +RUN mkdir -p function +RUN touch ./function/__init__.py + +WORKDIR /home/app/function/ +COPY function/requirements.txt . + +RUN pip install -r requirements.txt --target=/home/app/python + +WORKDIR /home/app/ + +USER root + +COPY function function + +# Allow any user-id for OpenShift users. +RUN chown -R app:app ./ && \ + chmod -R 777 /home/app/python + +USER app + +ENV fprocess="python3 index.py" +ENV mode="streaming" +EXPOSE 8080 + +HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 + +CMD ["fwatchdog"]