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

Open
wants to merge 1 commit into
base: 1-8-stable
Choose a base branch
from

Conversation

admtnnr
Copy link

@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.

I targeted the 1-8-stable branch instead of main as this is a blocking bug.

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.

1 participant