The Dockerfile language is treated as a special case for faas-cli, instead of building with a pre-defined entrypoint abstracted from the user, the whole contents of a given folder are used to build an image.
The default Dockerfile shows how to fork a CLI process once per request, however you can put whatever you like in the Dockerfile.
The example uses classic-watchdog, however the of-watchdog and existing Dockerfiles are supported too. Just make sure that whatever you use conforms to the OpenFaaS Workloads defintion.
FROM ghcr.io/openfaas/classic-watchdog:0.2.1 as watchdog
FROM alpine:3.18
RUN mkdir -p /home/app
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog
# Add non root user
RUN addgroup -S app && adduser app -S -G app
RUN chown app /home/app
WORKDIR /home/app
USER app
# Populate example here - i.e. "cat", "sha512sum" or "node index.js"
ENV fprocess="cat"
# Set to true to see request in function logs
ENV write_debug="false"
EXPOSE 8080
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1
CMD ["fwatchdog"]
To fork curl for every HTTP request, add it to the Alpine Linux container:
+RUN apk add --no-cache curl
Next, change fprocess to: xargs curl -s.
The xargs helper will take the request body and convert it into arguments for curl.