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

Enable layer-by-layer caching of Dockerfile instructions for all images specified in werf.yaml #5974

Open
1 task done
alexey-igrychev opened this issue Feb 15, 2024 · 9 comments

Comments

@alexey-igrychev
Copy link
Member

Before proceeding

  • I didn't find a similar issue

Problem

When using Buildah, users can enable layer-by-layer caching of Dockerfile instructions via the staged directive:

# werf.yaml
image: example
dockerfile: ./Dockerfile
staged: true

However, currently, there is no way to enable this feature globally for all images. This limitation requires users to specify the caching option individually for each image, which can be tedious and error-prone in projects with multiple images.

Solution (if you have one)

Add the staged option in the meta section of werf.yaml to activate layer-by-layer caching for all images at once.

project: app
configVersion: 1
build:
  staged: true

Additional information

Details on layer-by-layer caching can be found in the werf documentation: werf layer-by-layer caching.

@Bharadwajshivam28
Copy link

Hey @alexey-igrychev I am new and wanted to contribute.
Can I work on this issue?

@Bharadwajshivam28
Copy link

Can you please share steps to get started?

@alexey-igrychev
Copy link
Member Author

Hello, and thank your interest in this issue! ❤️

  • Begin by understanding how the werf.yaml configuration is read and processed, then look into how the current staged directive works for individual images and where it is used.
  • After that, you will have enough knowledge to add the new staged directive under the build section and the rest of the code.
    • Ensure that an image-specific staged setting overrides the common one, maintaining flexibility for individual configurations:
      project: app
      configVersion: 1
      build:
        staged: true
      ---
      image: example
      dockerfile: ./Dockerfile
      staged: false
  • Finally, you should update documentation here and here.

Layer-by-layer caching works only with the Buildah backend and you can find the necessary setup instructions here.

Don't hesitate to reach out if you have any questions or need help along the way. 🙌🏼

@Bharadwajshivam28
Copy link

Bharadwajshivam28 commented Feb 20, 2024

Hey @alexey-igrychev Thanks for helping me..
I had a few doubts-

  1. we have many werf.yaml files so which one should I look and understand the code of that file?

  2. You pointed to look into pkg/config/image_from_dockerfile.go file and see how the Staged is used but when i see it then i think it is used in the function

func (c *ImageFromDockerfile) IsStapel() bool {
	return false
} 

and it always returns false so i cant understand what to look into this file?

@Bharadwajshivam28
Copy link

Bharadwajshivam28 commented Feb 20, 2024

Our end goal is to enable layer-by-layer caching globally in the werf.yaml file hence we can add the staged option in the meta section of the werf.yaml

@alexey-igrychev
Copy link
Member Author

  1. All files in the config folder related to directives in the werf.yaml and their processing.
  2. I suggested looking at the usage of the staged option – it appears in six files:
    image

@Bharadwajshivam28
Copy link

Thanks I will look into it

@Bharadwajshivam28
Copy link

Hey @alexey-igrychev I looked into the files and dir mentioned by you and I will start working on it..

Just a question: can you please share some steps to get started?

@alexey-igrychev
Copy link
Member Author

alexey-igrychev commented Feb 26, 2024

Hey!

To get started with setting up werf using the Buildah backend, along with an example project, check out the documentation here. Once you're set up, don't forget to follow the contributing guidelines which you can find here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants