Skip to content

Commit

Permalink
Remove gevent and use waitress in all templates
Browse files Browse the repository at this point in the history
**What**
- Update all templates to use waitress instead of gevent.  This avoids
  the need to install things like gcc, make, or libffi-dev into the
  alpine images. The user can still install these via the
  ADDITIONAL_PACKAGES build arg, if they are needed.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
  • Loading branch information
LucasRoesler authored and alexellis committed May 2, 2020
1 parent cb68fbf commit e815593
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 30 deletions.
2 changes: 1 addition & 1 deletion template/python27-flask/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM python:2.7-alpine

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
Expand Down
4 changes: 2 additions & 2 deletions template/python3-flask-armhf/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM armhf/python:3.6-alpine

ARG ADDITIONAL_PACKAGE

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog

RUN apk --no-cache add musl-dev gcc make openssl-dev libffi-dev
RUN apk --no-cache add openssl-dev ${ADDITIONAL_PACKAGE}

# Add non root user
RUN addgroup -S app && adduser app -S -G app
Expand Down
8 changes: 2 additions & 6 deletions template/python3-flask-armhf/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from flask import Flask, request
from function import handler
#from gevent.wsgi import WSGIServer
from gevent.pywsgi import WSGIServer
from waitress import serve

app = Flask(__name__)

Expand All @@ -27,7 +26,4 @@ def main_route(path):
return ret

if __name__ == '__main__':
#app.run(host='0.0.0.0', port=5000, debug=False)

http_server = WSGIServer(('', 5000), app)
http_server.serve_forever()
serve(app, host='0.0.0.0', port=5000)
2 changes: 1 addition & 1 deletion template/python3-flask-armhf/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flask
gevent
waitress

2 changes: 1 addition & 1 deletion template/python3-flask-debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM python:3.7-slim-buster

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
Expand Down
7 changes: 2 additions & 5 deletions template/python3-flask-debian/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from flask import Flask, request
from function import handler
#from gevent.wsgi import WSGIServer
from gevent.pywsgi import WSGIServer
from waitress import serve

app = Flask(__name__)

Expand All @@ -27,6 +26,4 @@ def main_route(path):
return ret

if __name__ == '__main__':

http_server = WSGIServer(('0.0.0.0', 5000), app)
http_server.serve_forever()
serve(app, host='0.0.0.0', port=5000)
2 changes: 1 addition & 1 deletion template/python3-flask-debian/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flask
gevent
waitress

4 changes: 2 additions & 2 deletions template/python3-flask/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM python:3.7-alpine

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
Expand All @@ -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 musl-dev gcc make ${ADDITIONAL_PACKAGE}
RUN apk --no-cache add openssl-dev ${ADDITIONAL_PACKAGE}

# Add non root user
RUN addgroup -S app && adduser app -S -G app
Expand Down
8 changes: 2 additions & 6 deletions template/python3-flask/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from flask import Flask, request
from function import handler
#from gevent.wsgi import WSGIServer
from gevent.pywsgi import WSGIServer
from waitress import serve

app = Flask(__name__)

Expand All @@ -27,7 +26,4 @@ def main_route(path):
return ret

if __name__ == '__main__':
#app.run(host='0.0.0.0', port=5000, debug=False)

http_server = WSGIServer(('', 5000), app)
http_server.serve_forever()
serve(app, host='0.0.0.0', port=5000)
2 changes: 1 addition & 1 deletion template/python3-flask/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flask
gevent
waitress

4 changes: 2 additions & 2 deletions template/python3-http-armhf/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM armhf/python:3.6-alpine

ARG ADDITIONAL_PACKAGE
Expand Down Expand Up @@ -43,4 +43,4 @@ ENV upstream_url="http://127.0.0.1:5000"

HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1

CMD ["fwatchdog"]
CMD ["fwatchdog"]
4 changes: 2 additions & 2 deletions template/python3-http/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM openfaas/of-watchdog:0.7.7 as watchdog
FROM python:3.7-alpine

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
Expand Down Expand Up @@ -50,4 +50,4 @@ ENV upstream_url="http://127.0.0.1:5000"

HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1

CMD ["fwatchdog"]
CMD ["fwatchdog"]

0 comments on commit e815593

Please sign in to comment.