-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
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:
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:
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