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

List all images and build only the ones that changed #16

Open
Perados opened this issue Aug 30, 2021 · 1 comment
Open

List all images and build only the ones that changed #16

Perados opened this issue Aug 30, 2021 · 1 comment

Comments

@Perados
Copy link

Perados commented Aug 30, 2021

Hi!

I am trying to use docker-bakery in my CI/CD pipelines. The goal is to, whenever someone merges to master, build only the images that changed, and their children, avoiding building the children twice if both the parent and the children changed.

This is easy locally, because you know which files you edited, so you just go to those and run the build command. In the CI/CD (I'm using Gitlab), I can list all the Docker.template files that changed since the last merge, but I still need to find a way to avoid building parent and child if both changed. My idea was to use the show-structure command and filter using that, but the output is very difficult to parse. I think adding a json output option would be very useful.

I also tried using the images' digests to detect if something changed or not, but those change every time, even if the image is exactly the same, I think this happens because of the BAKERY_BUILD_DATE env variable that changes every time automatically.

I am also open to suggestions as to how automate this. Maybe I am just doing everything wrong! 😄

Thank you in advance!

@operatorequals
Copy link

What I guess you could do on the subject is to change the modification times for the Dockerfiles.
Specifically you can do the following:

MDATE=$(git log <Dockerfile> | head -3 | grep Date | cut -d ' ' -f 4-8)
touch -m $MDATE <Dockerfile>

This way, last commit date for each Dockerfile will be set as the modification time and will work with make, etc.

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

No branches or pull requests

2 participants