-
Notifications
You must be signed in to change notification settings - Fork 4k
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
assets: allow passing --output flag to Docker build #20566
Labels
@aws-cdk/assets
Related to the @aws-cdk/assets package
effort/small
Small work item – less than a day of effort
feature-request
A feature should be added or improved.
p2
Comments
vincent-dm
added
feature-request
A feature should be added or improved.
needs-triage
This issue or PR still needs to be triaged.
labels
Jun 1, 2022
github-actions
bot
added
the
@aws-cdk/assets
Related to the @aws-cdk/assets package
label
Jun 1, 2022
otaviomacedo
added
p2
effort/small
Small work item – less than a day of effort
and removed
needs-triage
This issue or PR still needs to be triaged.
labels
Jun 30, 2022
4 tasks
mergify bot
pushed a commit
that referenced
this issue
Jan 9, 2023
This adds the `--output` flag as an option when building docker containers. This fixes #20566. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
DerkSchooltink
pushed a commit
to DerkSchooltink/aws-cdk
that referenced
this issue
Jan 23, 2023
This adds the `--output` flag as an option when building docker containers. This fixes aws#20566. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
@aws-cdk/assets
Related to the @aws-cdk/assets package
effort/small
Small work item – less than a day of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
AssetImageProps
should allow setting thedocker build
--output
flag.Use Case
Specifically, we need to set
--output=type=docker
. It could also be expressed by the shorthand--load
flag, but I would prefer a solution which allows the user to pass any--output
, to avoid having to adapt CDK every time Docker adds new output options.Background
We use CDK to build and deploy an ARM64 image on an x86-based (i.e. AMD64) Linux EC2 instance. Only Docker desktop offers multi-platform builds out of the box, so we had to install it, as per Docker's guide. We make
buildx
the default builder by runningdocker buildx install
and then configuring a builder forarm64
. Invokingdocker build ...
(like CDK does) is then actually re-routed to usebuildx
instead of the legacy Docker builder.BUT
buildx
by default doesn't publish the built image into the local registry and requires an additional--output
flag (or a shorthand like--load
) to actually store and use the image that was built. This is reflected by warnings shown bybuildx
when invokingdocker build
without setting the--output
flag (or any of its shorthands like--push
or--load
:Because CDK
AssetImageProps
builder API doesn't allow us to set the output for thedocker build
step, it fails after building because it tries to tag an image which doesn't exist:Workarounds like @nathanpeck's #12472 (comment) are not an option for us, since we need to be able to synthesize our CDK stack without building all the Docker images (which requires long compilation etc).
Our current workaround is to rename the
docker
binary todocker_real
and instead create adocker
bash script on the path which adds the flag:But this is obviously a hack and the proper solution would be for CDK
AssetImageProps
builder to allow us to add the--output
flag (or preferably: any flag) to its invocation ofdocker build
.Proposed Solution
The
AssetImageProps
builder should get a new methodoutput
, which works similar to the existingbuildArgs
method.For example, calling this new
output
method with a map like{"type": "local", "dest": "path"}
would result in--output=type=local&dest=path
.Other Information
No response
Acknowledgements
CDK version used
2.26.0
Environment details (OS name and version, etc.)
Amazon Linux 2
The text was updated successfully, but these errors were encountered: