Skip to content

ecr-assets: incomplete .dockerignore support #4450

@kolomied

Description

@kolomied

Introduced by #4104.

CDK does not handle the common "exclude everything except" pattern for .dockerignore files:

# Ignore everything
*
# Allow files and directories
!/src/**

Quote from Docker docs:

... you may want to specify which files to include in the context, rather than which to exclude. To achieve this, specify * as the first pattern, followed by one or more ! exception patterns.

With the current implementation the first 'star' glob effectively excludes everything from the asset folder dyring synth stage. Consequently, deploy stage fails to build the docker image.

Reproduction Steps

  1. Create a .dockerignore file next to you Dockerfile with * pattern, like this:
    # Ignore everything
    *
    # Allow files and directories
    !/src/**
  2. Run cdk deploy

Error Log

unable to prepare context: unable to evaluate symlinks in Dockerfile path: CreateFile C:\Dev\GitHub\playground\EcsWindowsCluster\src\Deployment\cdk.out\asset.1ebc9d3ac2033816c4abb63e4afd69d350b4aba8704cc9236b82ea520b74f4b0\Dockerfile: The system cannot find the file specified.

 ❌  win failed: Error: docker build --tag 305168429857.dkr.ecr.eu-west-1.amazonaws.com/cdk/win:latest cdk.out\asset.1ebc9d3ac2033816c4abb63e4afd69d350b4aba8704cc9236b82ea520b74f4b0 exited with error code 1
docker build --tag 305168429857.dkr.ecr.eu-west-1.amazonaws.com/cdk/win:latest cdk.out\asset.1ebc9d3ac2033816c4abb63e4afd69d350b4aba8704cc9236b82ea520b74f4b0 exited with error code 1

Environment

  • CLI Version : 1.12.0 (build 923055e)
  • OS : Windows

This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-ecrRelated to Amazon Elastic Container RegistrybugThis issue is a bug.in-progressThis issue is being actively worked on.management/devenvRelated to CDK development/build environmentp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions