openfaas / python-flask-template

HTTP and Flask-based OpenFaaS templates for Python 3
MIT License
85 stars 86 forks source link

feat: user multi-stage builds and remove apt and pip caches #62

Closed LucasRoesler closed 1 year ago

LucasRoesler commented 1 year ago

Recreated for Hacktoberfest ;)

  1. Remove apt cache after running apt-get
  2. Pass --no-cache-dir to the pip command
  3. Use multi-stage builds to remove the test layers from the final image.

Motivation and Context

Resolves #57 Relates to #55

How Has This Been Tested?

$ faas-cli new echo0 --lang python3-flask 
$ faas-cli new echo1 --lang python3-http

$ faas-cli build -f echo0.yml --no-cache
# truncated
Image: echo0:latest built.
[0] < Building echo0 done in 37.65s.
[0] Worker done.

Total build time: 37.65s

$ faas-cli build -f echo1.yml --no-cache
# truncated
Image: echo1:latest built.
[0] < Building echo1 done in 32.50s.
[0] Worker done.

Total build time: 32.50s

Types of changes

Checklist:

alexellis commented 1 year ago

I'll get this merged, thank you so much. Could you send similar to the Python templates in openfaas/templates?