FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.9.10 as watchdog FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.11-alpine COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog ARG ADDITIONAL_PACKAGE RUN apk --no-cache add musl-dev gcc make ${ADDITIONAL_PACKAGE} # Add non root user RUN addgroup -S app && adduser app -S -G app RUN chown app /home/app USER app ENV PATH=$PATH:/home/app/.local/bin WORKDIR /home/app/ COPY requirements.txt . USER root RUN pip install -r requirements.txt USER app COPY index.py . RUN mkdir -p function RUN touch ./function/__init__.py WORKDIR /home/app/function/ COPY function/requirements.txt . RUN pip install --user -r requirements.txt WORKDIR /home/app/ USER root # remove build dependencies RUN apk del musl-dev gcc make COPY function function RUN chown -R app:app ./ USER app ENV fprocess="uvicorn index:app --workers 1 --host 0.0.0.0 --port 8000" ENV cgi_headers="true" ENV mode="http" ENV upstream_url="http://127.0.0.1:8000" HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 CMD ["fwatchdog"]