aws-ecr-assets: DockerImageAsset is unusable with Docker Buildkit builder, which is the default in recent Docker for Mac
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
BuildKit is the default builder on Docker for Mac and `DockerImageAsset` doesn't appear to set an output, so builds will fail as they aren't saved to the local docker registry (only build cache by default).
### Expected Behavior
DockerImageAsset should either configure `output=docker` or correctly use Buildkit to push to the ECR Repository when Buildkite is the default builder.
### Current Behavior
Building on a mac with a recent Docker for Mac (mine is 4.0.1), deploy will fail with this error:
> Error response from daemon: No such image: cdkasset-ba6f83a156c20286cbce8a4f5c837ca1a2a4e01d9b3de43cc6e9c2fa4a6e6fc0:latest
and a warning earlier that makes it clear the issue:
> time="2022-09-10T12:52:04+10:00" level=warning msg="No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load"
### Reproduction Steps
```
const image = new ecrAssets.DockerImageAsset(this, 'DockerImage', {
directory: path.join(__dirname, '/../docker/agent'),
});
```
### Possible Solution
This could possibly be worked around with [supporting `--output`](https://github.com/aws/aws-cdk/issues/20566), although given Buildkit is likely the future default, this seems like a bad option.
### Additional Information/Context
This is mentioned in https://github.com/aws/aws-cdk/issues/12472#issuecomment-904937818 and https://github.com/aws/aws-cdk/issues/20566, but neither of the comments make it clear that this is essentially a show stopper (without good workarounds) for anyone on a recent Docker for Mac.
### CDK CLI Version
2.39.1 (build f188fac)
### Framework Version
_No response_
### Node.js Version
v18.8.0
### OS
macOS 12.4
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start from the DockerImageAsset entry point and reproduce the asset build with Docker BuildKit enabled, checking how the build result is made available to the local Docker registry or pushed to ECR. Done means the reproduced deployment no longer fails with “No such image” and the BuildKit output warning is addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, typescript
- Domain
- cloud, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100