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

(aws_ecr_assets): DockerImageAsset cache_from not compatible with Docker < V23 #27752

Open
BevcJ opened this issue Oct 30, 2023 · 2 comments
Open
Labels
@aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@BevcJ
Copy link

BevcJ commented Oct 30, 2023

Describe the bug

In aws-cdk=2.83.0, the --cache-from option in DockerImageAsset is generated in an incorrect format for Docker versions below v23. This conflicts with the default CodeBuild image and the available options in LinuxBuildImage, all using Docker v20, rendering the argument incompatible. Upgrading to version aws-cdk=2.103.1 resolves the issue as the default CodeBuild image shifts to the latest version using Docker v23.

Expected Behavior

As I understand for docker versions < 23.0 the argument should be:

docker build --build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from aws_account_id.dkr.ecr.region.amazonaws.com/test-cache:latest --tag aws_account_id.dkr.ecr.region.amazonaws.com/test-cache:latest .

Note:

  • The specific image must be pulled before executing the build command.
  • Setting DOCKER_BUILDKIT=1

Current Behavior

--cache-from arguments passed this way does not work.

docker build --build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from type=registry,ref=aws_account_id.dkr.ecr.region.amazonaws.com/test-cache:latest --tag aws_account_id.dkr.ecr.region.amazonaws.com/test-cache:latest .

Logs:

#4 importing cache manifest from type=registry
#4 sha256:93f1eeb6dd5502f7b6fb1241aec4210182a26fdda27e6428206dbb834c4cb716
#4 ERROR: invalid reference format
 
#10 importing cache manifest from ref=aws_account_id.dkr.ecr.region.amazonaws.com/test-cache:latest
#10 sha256:211a9356f59d3fa5e67b3c2ce00d0d0c859b8ecc2c83ab2fe18913486a993e6b
#10 ERROR: invalid reference format

Reproduction Steps

I can provide a small example or a repository if needed for further clarification.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.83.0

Framework Version

No response

Node.js Version

v18.18.2

OS

mac

Language

Python

Language Version

No response

Other information

No response

@BevcJ BevcJ added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 30, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets label Oct 30, 2023
@pahud
Copy link
Contributor

pahud commented Oct 31, 2023

Do you mean aws-cdk 2.103.1 has fixed this issue but you have to stick to 2.83.0? What is your expectation?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Oct 31, 2023
@BevcJ
Copy link
Author

BevcJ commented Nov 2, 2023

Indeed, the compatibility seems to align from a certain version of aws-cdk onwards, specifically when latest codebuild images became available (STANDARD_7_0, AMAZON_LINUX_2_5) and are used by default in cdk pipelines.

However, issue still persists when utilizing the latest aws-cdk version with CodeBuild images that use Docker versions < v23 (for example STANDARD_6_0 ).

My expectation would be to update the documentation to include information on version dependencies and the implications of using the cache_from argument.

@pahud pahud added p3 and removed p2 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

2 participants