mirror of
https://github.com/clearlinux/dockerfiles.git
synced 2026-09-06 05:32:03 +00:00
Add OpenFaaS Clear Linux based python3 template
Signed-off-by: Qi Zheng <qi.zheng@intel.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
FROM openfaas/classic-watchdog:0.18.1 as watchdog
|
||||
|
||||
FROM clearlinux/python:3
|
||||
|
||||
ARG swupd_args
|
||||
|
||||
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
|
||||
RUN chmod +x /usr/bin/fwatchdog
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY index.py .
|
||||
# pip install python packages if required
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# install bundles if required
|
||||
# PLEASE input bundle line by line
|
||||
COPY bundles.txt .
|
||||
RUN for bundle in $(cat bundles.txt); do \
|
||||
swupd bundle-add $bundle $swupd_args; \
|
||||
done
|
||||
|
||||
RUN mkdir -p function
|
||||
RUN touch ./function/__init__.py
|
||||
WORKDIR /root/function/
|
||||
# pip install python packages if required
|
||||
COPY function/requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# 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 /root/
|
||||
COPY function function
|
||||
|
||||
ENV fprocess="python3 index.py"
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1
|
||||
|
||||
CMD ["fwatchdog"]
|
||||
@@ -0,0 +1,7 @@
|
||||
def handle(req):
|
||||
"""handle a request to the function
|
||||
Args:
|
||||
req (str): request body
|
||||
"""
|
||||
|
||||
return req
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (c) Alex Ellis 2017. All rights reserved.
|
||||
# Copyright (c) OpenFaaS Author(s) 2018. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
import sys
|
||||
from function import handler
|
||||
|
||||
def get_stdin():
|
||||
buf = ""
|
||||
while(True):
|
||||
line = sys.stdin.readline()
|
||||
buf += line
|
||||
if line == "":
|
||||
break
|
||||
return buf
|
||||
|
||||
if __name__ == "__main__":
|
||||
st = get_stdin()
|
||||
ret = handler.handle(st)
|
||||
if ret != None:
|
||||
print(ret)
|
||||
@@ -0,0 +1,2 @@
|
||||
language: python3
|
||||
fprocess: python3 index.py
|
||||
Reference in New Issue
Block a user