-
Notifications
You must be signed in to change notification settings - Fork 224
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
faas-cli using buildkit and / or --cache-from Docker options for CI build process optimization #842
Comments
The build arg This will require that you have enabled Buildkit by default in your Docker, for example setting the env variable The Because you mention Github Actions, checkout our blog post https://www.openfaas.com/blog/openfaas-functions-with-github-actions/. You can see it also using |
Thank you very much for your help. As for the env variables for buildkit I didn't had to change anything in my Github action workflow but I have added those 2 instructions for using the cache properly with this action.
- name: Build and Push the OpenFaaS function
uses: docker/build-push-action@v2
...
with:
...
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/my/path/openfaas_fn:latest
cache-to: type=inline |
Why did your build take 30 minutes? |
My docker image contains some instructions to pip install pandas and as it required some rebuild it took a long time. Maybe a better approach would be to build a base image including my requirements but I need to study more about how to use a private function store I can pull. To be more precise:
|
The idiomatic way to solve this problem would be to create a base image with pandas already installed |
I will do at some point but as the base images in openfaas come from the template store I guess I will need to create at first my own template including my requirements and push it in a store. |
My actions before raising this issue
How to use
buildkit
cache optimization in combination with--cache-from
argument option to accelerate the build with faas-cli in a CI pipeline (I am trying it with Github actions)Expected Behaviour
Use remote registry cached layers to build only the necessary changes and not the whole image each time the build process is launched from faas-cli in a CI pipeline
Current Behaviour
The image is built from scratch which takes quite some time.
Possible Solution
Allow
--cache-from
argument andbuildkit
Steps to mimic
Reproduce (for bugs)Source : Specifying external cache sources
Context
In a CI process like Github action the Docker image build process is not using (by default for what I could check) any cache so the image is built from the ground.
As my openfaas functions are using pandas python library some steps in the docker build process are taking a very long time.
But those layers are not changing frequently, so locally on the workstation as the cache is used the build process is fast but not on the CI pipeline as all the layers are rebuilt.
Your Environment
FaaS-CLI version ( Full output from:
faas-cli version
): 0.12.14Docker version
docker version
(e.g. Docker 17.0.05 ): Github action Docker version so I am not sure exactlyAre you using Docker Swarm or Kubernetes (FaaS-netes)? Target is Kubernetes but it doesn't matter here I guess
Operating System and version (e.g. Linux, Windows, MacOS): Github CI
Code example or link to GitHub repo or gist to reproduce problem:
Other diagnostic information / logs from troubleshooting guide
If using Swarm, run the following and include the output:
Next steps
You may join Slack for community support.
The text was updated successfully, but these errors were encountered: