mirror of
https://github.com/clearlinux/dockerfiles.git
synced 2026-11-21 21:34:28 +00:00
Add OpenFaaS dockerfile template
Signed-off-by: Qi Zheng <qi.zheng@intel.com>
This commit is contained in:
@@ -10,6 +10,29 @@ Steps could refer to
|
||||
|
||||
[OpenFaaS workshop](https://github.com/openfaas/workshop)
|
||||
|
||||
### dockerfile-clearlinux
|
||||
1. `mkdir test && cd test`
|
||||
2. `cp -r "<your-dockerfiles-path>"/FaaS/OpenFaaS/template/. template/`
|
||||
3. `faas-cli new --lang dockerfile-clearlinux hello-dockerfile --prefix="<your-docker-username-here>"`
|
||||
|
||||
Files tree as below.
|
||||
>
|
||||
├── hello-dockerfile
|
||||
│ ├── bundles.txt
|
||||
│ └── Dockerfile
|
||||
├── hello-dockerfile.yml
|
||||
|
||||
* Put the required Clear Linux bundles in the "bundles.txt".
|
||||
For example,
|
||||
|
||||
`echo "openblas" >> hello-dockerfile/bundles.txt`
|
||||
`echo "wget" >> hello-dockerfile/bundles.txt`
|
||||
4. Replace the "cat" in the Dockerfile line below per your requirement.
|
||||
ENV fprocess="cat"
|
||||
5. `faas-cli up -f hello-dockerfile.yml`
|
||||
|
||||
Then you can invoke your python function by OpenFaas UI or faas-cli.
|
||||
|
||||
### python3-clearlinux
|
||||
1. `mkdir test && cd test`
|
||||
2. `cp -r "<your-dockerfiles-path>"/FaaS/OpenFaaS/template/. template/`
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
FROM openfaas/classic-watchdog:0.18.1 as watchdog
|
||||
|
||||
FROM clearlinux:base
|
||||
|
||||
ARG swupd_args
|
||||
|
||||
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
|
||||
RUN chmod +x /usr/bin/fwatchdog
|
||||
|
||||
# Add non root user
|
||||
RUN useradd app
|
||||
|
||||
RUN mkdir -p /root/function
|
||||
WORKDIR /root/function/
|
||||
|
||||
# install bundles if required
|
||||
# PLEASE input bundle line by line
|
||||
COPY function/bundles.txt .
|
||||
RUN for bundle in $(cat bundles.txt); do \
|
||||
swupd bundle-add $bundle $swupd_args; \
|
||||
done
|
||||
|
||||
|
||||
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"]
|
||||
@@ -0,0 +1,36 @@
|
||||
FROM openfaas/classic-watchdog:0.18.1 as watchdog
|
||||
|
||||
FROM clearlinux:base
|
||||
|
||||
ARG swupd_args
|
||||
|
||||
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
|
||||
RUN chmod +x /usr/bin/fwatchdog
|
||||
|
||||
# Add non root user
|
||||
RUN useradd app
|
||||
|
||||
WORKDIR /root/function/
|
||||
|
||||
# install bundles if required
|
||||
# PLEASE input bundle line by line
|
||||
COPY function/bundles.txt .
|
||||
RUN for bundle in $(cat bundles.txt); do \
|
||||
swupd bundle-add $bundle $swupd_args; \
|
||||
done
|
||||
|
||||
|
||||
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=5s CMD [ -e /tmp/.lock ] || exit 1
|
||||
|
||||
CMD ["fwatchdog"]
|
||||
@@ -0,0 +1 @@
|
||||
language: dockerfile-clearlinux
|
||||
Reference in New Issue
Block a user