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 cacheTo property causes "unknown flag: --cache-to" error #24685
Comments
Unfortunately CodeBuild doesn't natively support buildx at this moment. I am not sure if there's any workaround but we definitely should improve our docs on this. |
Even with a custom build image with buildx installed and a container driver selected, I'm not sure there's a way to tell DockerImageAsset() to use the container driver rather than the default docker driver which doesn't support CodeBuild output looks like:
|
AWS CDK honors
|
Yes overriding
|
Do you mind showing in a bit more detail how you got this working? It seemed logical enough to me, create the script, tell CodeBuild to use it, but I must be doing something wrong because I can't get the script to execute. When it's time for docker to run, it just throws the error |
@noreason I created a custom image based on the official AWS CodeBuild images (in my case
In the
Build the image, push it to ECR or Docker Hub, and configure it as your custom build image. You'll need to include these commands in your
And set these environment variables:
Be aware ECR doesn't support cache manifests yet so if you're not using your own or an external image repository you'll need to wait for aws/containers-roadmap#876. |
Thank you for this explanation. Bummer the amount of workaround needed to get this going. |
Describe the bug
CDK DockerImageAsset has a recently-added cacheTo property.
This option should allow the Docker build cache to be exported, in order to be used to improve performance of future builds.
But instead using this property in a CDK CodePipeline causes a CodeBuild error.
Expected Behavior
The cacheTo property should save a Docker build cache to the selected destination, in this case ECR.
Current Behavior
Instead the build process fails with the following
unknown flag: --cache-to
error:Reproduction Steps
Possible Solution
This seems to be because the CodeBuild Docker build process isn't using BuildKit.
I've tried using the following config but it still runs
docker build
rather thandocker buildx build
. Adding the same environment toselfMutationCodeBuildDefaults
also doesn't seem to help.Additional Information/Context
Some properties have a comment referencing BuildKit as a requirement, perhaps this property also needs a similar comment:
Although I haven't been able to find documentation on enabling BuildKit for DockerImageAsset.
CDK CLI Version
2.69.0
Framework Version
No response
Node.js Version
16
OS
LinuxBuildImage.STANDARD_6_0
Language
Typescript
Language Version
No response
Other information
The pull requests adding the cacheTo property: #24024 & #24524
The text was updated successfully, but these errors were encountered: