aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

feat(assets): support drop-in docker replacements by setting `$CDK_DOCKER`

Open misterjoshua opened this issue 3 years ago • 14 comments
trafficstars

This PR introduces the ability for users to change the command used for building and publishing Docker images to a drop-in replacement like the Depot Docker shim. To change the docker command, the user provides the alternative command via an environment variable named CDK_DOCKER.

There's already something similar in core's asset bundling, but it applies only to bundling and not to building and publishing Docker image assets.

https://github.com/aws/aws-cdk/blob/3e55092fb70e0ec74ee7c4144d6e39a29d8757ae/packages/%40aws-cdk/core/lib/bundling.ts#L523

Fixes #21836


All Submissions:

Adding new Unconventional Dependencies:

  • [ ] This PR adds new unconventional dependencies following the process described here

New Features

  • [ ] Have you added the new feature to an integration test?
    • [ ] 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

Depends-On: https://github.com/aws/aws-cdk/pull/22194

misterjoshua avatar Aug 30 '22 23:08 misterjoshua

gitpod-io[bot] avatar Aug 30 '22 23:08 gitpod-io[bot]

How about getting that custom executable to replace docker to asset step's image(s)? Should custom image be used, some installation added to steps or what? I think this should be mentioned in documentation.

Hi-Fi avatar Aug 31 '22 05:08 Hi-Fi

How about getting that custom executable to replace docker to asset step's image(s)? Should custom image be used, some installation added to steps or what? I think this should be mentioned in documentation.

@Hi-Fi Thanks for your comments, but I need more clarification. Do you mean to suggest we include documentation on installing third-party tools alongside the AWS CDK and instructions on using those tools with the AWS CDK? i.e., a tutorial on installing and using Depot to build Docker image assets? (curl https://... | sh && env CDK_DOCKER=depot-shim cdk deploy)

misterjoshua avatar Aug 31 '22 17:08 misterjoshua

How about getting that custom executable to replace docker to asset step's image(s)? Should custom image be used, some installation added to steps or what? I think this should be mentioned in documentation.

@Hi-Fi Thanks for your comments, but I need more clarification. Do you mean to suggest we include documentation on installing third-party tools alongside the AWS CDK and instructions on using those tools with the AWS CDK? i.e., a tutorial on installing and using Depot to build Docker image assets? (curl https://... | sh && env CDK_DOCKER=depot-shim cdk deploy)

As asset stage is a bit special in pipelines, and it's configuration is just one that is offered. So documentation should have recommendation if to use custom build image with executable included or add installation command to some assetPublishingCodeBuildDefaults.

Using cdk deploy is different thing, as with that there's no need to worry about stages. And in that I don't think it's needed to tell how to install tool needed.

Hi-Fi avatar Aug 31 '22 18:08 Hi-Fi

How about getting that custom executable to replace docker to asset step's image(s)? Should custom image be used, some installation added to steps or what? I think this should be mentioned in documentation.

@Hi-Fi Thanks for your comments, but I need more clarification. Do you mean to suggest we include documentation on installing third-party tools alongside the AWS CDK and instructions on using those tools with the AWS CDK? i.e., a tutorial on installing and using Depot to build Docker image assets? (curl https://... | sh && env CDK_DOCKER=depot-shim cdk deploy)

As asset stage is a bit special in pipelines, and it's configuration is just one that is offered. So documentation should have recommendation if to use custom build image with executable included or add installation command to some assetPublishingCodeBuildDefaults.

Using cdk deploy is different thing, as with that there's no need to worry about stages. And in that I don't think it's needed to tell how to install tool needed.

@Hi-Fi Thanks for clarifying! I'll take a crack at adding documentation to the CDK Pipelines README as well.

misterjoshua avatar Aug 31 '22 19:08 misterjoshua

@mergifyio update

misterjoshua avatar Sep 06 '22 18:09 misterjoshua

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 06 '22 18:09 mergify[bot]

I think the CDK_DOCKER feature was mostly intended for testing, but I guess I don't mind supporting this. A couple of doc updates and then this is good to go.

Sounds good. I'll get to these changes this afternoon or evening after work at the latest.

(Sidebar: the more I see and learn about Docker, the less I like supporting it. It seems everyone has very specific opinions on how it should be used in their specific use cases, leading to a proliferation of flags and tweaks that are tough to maintain... 😔)

Agreed. The CDK really took the bull by the horns by tackling the issue of building/publishing containers. I think a lot of users appreciate the help though, myself included.

misterjoshua avatar Sep 07 '22 15:09 misterjoshua

@mergifyio update

misterjoshua avatar Sep 12 '22 20:09 misterjoshua

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 12 '22 20:09 mergify[bot]

@mergifyio update

misterjoshua avatar Sep 21 '22 16:09 misterjoshua

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 21 '22 16:09 mergify[bot]

Needs https://github.com/aws/aws-cdk/pull/22194 to be merged first

rix0rrr avatar Sep 22 '22 15:09 rix0rrr

@Mergifyio update

rix0rrr avatar Sep 23 '22 07:09 rix0rrr

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 23 '22 07:09 mergify[bot]

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 241b3242ed61e34ffd3c188fe9e9ad005c6f93f1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

aws-cdk-automation avatar Sep 23 '22 08:09 aws-cdk-automation

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

mergify[bot] avatar Sep 23 '22 08:09 mergify[bot]