Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: stress test build #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions template/python3-flask/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN chmod +x /usr/bin/fwatchdog
ARG ADDITIONAL_PACKAGE
# Alternatively use ADD https:// (which will not be cached by Docker builder)

RUN apk --no-cache add openssl-dev ${ADDITIONAL_PACKAGE}
RUN apk --no-cache add openssl-dev apache2-utils curl vim ${ADDITIONAL_PACKAGE}

# Add non root user
RUN addgroup -S app && adduser app -S -G app
Expand All @@ -21,6 +21,7 @@ WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
COPY gconfig.py .

USER root
RUN pip install -r requirements.txt
Expand All @@ -40,12 +41,14 @@ WORKDIR /home/app/
USER root

COPY function function

RUN chown -R app:app ./

#configure WSGI server and healthcheck
USER app

ENV fprocess="python index.py"
# ENV fprocess="python index.py"
ENV fprocess="gunicorn -c gconfig.py index:app"

ENV cgi_headers="true"
ENV mode="http"
Expand Down
7 changes: 7 additions & 0 deletions template/python3-flask/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
DATE=`date +%Y%m%d%H%M%S`
DOCKER_IMAGE=lihodocker/faas-python3-gunicorn:$DATE

cmd="docker build -t $DOCKER_IMAGE ."
echo $cmd
eval $cmd
6 changes: 5 additions & 1 deletion template/python3-flask/function/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import time


def handle(req):
"""handle a request to the function
Args:
req (str): request body
"""

time.sleep(0.01)
print("hello world")
return req
12 changes: 12 additions & 0 deletions template/python3-flask/gconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""All config default settings can refer to:
https://github.com/benoitc/gunicorn/blob/master/gunicorn/config.py
"""

bind = "0.0.0.0:5000"
workers = 4
worker_class = "gthread"
threads = 1
timeout = 300
graceful_timeout = 30
loglevel = "debug"
max_requests = 10
1 change: 1 addition & 0 deletions template/python3-flask/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flask
waitress
gunicorn==19.9.0