Skip to content

(docker assets): .dockerignore is processed incorrectly before 1.73.0 and broken after 1.73.0 #13636

@mimozell

Description

@mimozell

I'm using ContainerImage.fromAsset to build a Docker image out of my source code, but the .dockerignore file is not correctly processed. My source tree is roughly as follows:

project:

  • build (contains jar)
  • infra (contains all the infrastructure code, and thus cdk.out)
  • src (contains all the source code)
  • Dockerfile
  • .dockerignore

.dockerignore contains:

**
!build/libs/*.jar

When using version 1.93.0, and looking at what is copied over to cdk.out I see the following:
Screenshot 2021-03-16 at 14 28 05
This means that only the . folders and files are copied over, completely ignoring what is in .dockerignore. I manage to locate this issue starting from version 1.73.0. In 1.72.0 I see the following, which is also incorrect:
Screenshot 2021-03-17 at 10 27 42
this is practically copying over all my files and again completely ignoring what is in .dockerignore. This is particularly a problem since I ask for everything to be ignored besides that jar. When I keep the .dockeringore file as it is above, cdk will try to copy everything to cdk.out including cdk.out, which is part of the infra directory and there we get a hell loop that of course breaks with the error:

Exception in thread "main" software.amazon.jsii.JsiiException: ENAMETOOLONG: name too long, copyfile '......../infra/cdk.out/asset.9722b878afbb14ee8bf21b7e0a90c692dcb9865f12e685f6e59aead58f9c9c44/infra/......

In order to avoid this error, I have to add the infra directory to the .dockerignore file explicitly, like this:

**
infra
!build/libs/*.jar

but it and everything that isn't the jar should've been ignored by **.

What did you expect to happen?

I expected the .dockeringore to be processed (correctly) because of this comment: #5807 (comment). I haven't seen anything like this as part of the documentation.

What actually happened?

Environment

  • CDK CLI Version :
  • Framework Version:
  • Node.js Version:
  • OS :
  • Language (Version):

Other


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/assetsRelated to the @aws-cdk/assets packagebugThis issue is a bug.closed-for-stalenessThis issue was automatically closed because it hadn't received any attention in a while.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions