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

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

Merged

Conversation

LucasRoesler
Copy link
Member

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

  • I have raised an issue to propose this change (required)
  • My issue has received approval from the maintainers or lead with the design/approved label

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
@alexellis
Copy link
Member

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

@alexellis alexellis merged commit 79b444b into openfaas:master Oct 5, 2022
alexellis added a commit that referenced this pull request Oct 5, 2022
Fixes: #63 - introduced via #62

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
jpauwels pushed a commit to jpauwels/python-flask-template that referenced this pull request Apr 15, 2023
Fixes: openfaas#63 - introduced via openfaas#62

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unnecessary package cache files for apt/pip, implement multistage builds to minimize container image
2 participants