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

builder/cache/options: fix order of build args when using registry #950

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

admtnnr
Copy link
Contributor

@admtnnr admtnnr commented Sep 18, 2024

Background

When using the build cache with the registry cache type the order of options given to docker build --cache-to appears to be significant and the ref option MUST come first, directly after the type=registry option.

The error looks like the following with the existing implementation that appends the ref option at the end of the builder/cache/options:

DEBUG [f3e45b60] Command: docker buildx build --push -t $ACCOUNT.dkr.ecr.us-east-2.amazonaws.com/$REPO:$SHA -t $ACCOUNT.dkr.ecr.us-east-2.amazonaws.com/$REPO:latest --cache-to type=registry,mode=max,compression=zstd,oci-mediatypes=true,image-manifest=true
,ref=$ACCOUNT.dkr.ecr.us-east-2.amazonaws.com/$REPO-build-cache --cache-from type=registry,ref=$ACCOUNT.dkr.ecr.us-east-2.amazonaws.com/$REPO-build-cache --label service="$APP" --file Dockerfile .
 DEBUG [f3e45b60] 	ERROR: "docker buildx build" requires exactly 1 argument.
 DEBUG [f3e45b60] 	See 'docker buildx build --help'.
 DEBUG [f3e45b60] 	
 DEBUG [f3e45b60] 	Usage:  docker buildx build [OPTIONS] PATH | URL | -
 DEBUG [f3e45b60] 	
 DEBUG [f3e45b60] 	Start a build
 DEBUG [f3e45b60] 	sh: 2: ,ref=$ACCOUNT.dkr.ecr.us-east-2.amazonaws.com/$REPO-build-cache: not found
  Finished all in 9.3 seconds

I can't just remove the other options because the oci-mediatypes=true,image-manifest=true options are required to use the build cache with ECR.

@admtnnr admtnnr changed the base branch from 1-8-stable to main October 1, 2024 16:28
@admtnnr admtnnr marked this pull request as draft October 1, 2024 16:55
@admtnnr admtnnr marked this pull request as ready for review October 1, 2024 16:55
@djmb
Copy link
Collaborator

djmb commented Oct 23, 2024

Thanks @admtnnr!

This seems like a strange requirement! Is this a Docker thing or just AWS specific? Either way I don't see a problem with changing it.

@djmb djmb merged commit bf8779c into basecamp:main Oct 23, 2024
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.

2 participants