(cdk-assets): TarballImageAsset fails when pushing a Windows image to ECR
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When using TarballImageAsset to push the image to ECR, we are getting the following error from CDK:
```
[0%] start: Publishing
[0%] start: Publishing
[50%] success: Published
[100%] fail: docker tag ${accountID}.dkr.ecr.${region}.amazonaws.com/test-container:2b05db45fbd5f2de3d16dcc2d354afca3f89037f71c594ea455c9b10bc31c8c2 exited with error code 1: Error parsing reference: "" is not a valid repository/tag: invalid reference format
```
The image that we tried to push to ECR is a Windows based image `mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019`, and the size of the image is around 9G.
But it works fine if we use AWS CLI and Docker CLI to push it to ECR. The issue seems to be related to the tag of the image but we are not able to specify the tag of the image via TarballImageAsset.
### Expected Behavior
The image would deploy successfully.
### Current Behavior
The image fails to deploy.
### Reproduction Steps
1. Build and compress a Docker image in a Windows machine using the following Dockerfile:
```
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN echo "Hello World!"
```
2. Deploy the CDK stack using `TarballImageAsset`
### Possible Solution
Not sure what the issue is but we found that when it does `docker tag ${accountID}.dkr.ecr.${region}.amazonaws.com/test-container:2b05db45fbd5f2de3d16dcc2d354afca3f89037f71c594ea455c9b10bc31c8c2`, looks like something is failing because of the image tag name.
The tag in the error message has double spaces after `docker tag`.
### Additional Information/Context
_No response_
### CDK CLI Version
2.23.0
### Framework Version
_No response_
### Node.js Version
14
### OS
Windows
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start at the TarballImageAsset publishing path and reproduce the failure with the supplied Windows Dockerfile and ECR deployment. Inspect how the source image tag is selected before the failing docker tag command; done means the image deploys successfully and the Windows case has regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100