Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mimozell opened this issue Mar 17, 2021 · 5 comments
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1

Comments

@mimozell
Copy link

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

@mimozell mimozell added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 17, 2021
@github-actions github-actions bot added the @aws-cdk/assets Related to the @aws-cdk/assets package label Mar 17, 2021
@eladb eladb added effort/small Small work item – less than a day of effort p1 labels Mar 18, 2021
@eladb eladb removed their assignment Mar 18, 2021
@guidobit
Copy link

guidobit commented Apr 7, 2021

Ah, this was bugging me today. Is there any possible workaround until this has been fixed?

@mimozell
Copy link
Author

mimozell commented Apr 8, 2021

Not that I know. But you can go back to a working version if you are not depending on the features/bugfixes introduced in later versions. I am depending on them, so my work is stalled for now :(

@ryparker
Copy link
Contributor

Hey @mimozell 👋

Thanks for bringing this to our attention.

This is marked as p1 which means it has been prioritized as important and should see attention soon, although please keep in mind that we do have a large number of issues at the moment. It may be some time before we are able to solve this particular issue. We use +1s to help us prioritize our work, and as always we are happy to take contributions if anyone is interested to pick this up and submit a PR (please make sure to follow our contribution guidelines.).

@ryparker ryparker removed the needs-triage This issue or PR still needs to be triaged. label Jun 18, 2021
@dashmug
Copy link

dashmug commented Nov 18, 2021

This affects me too.

@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 18, 2022
@rix0rrr rix0rrr reopened this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

No branches or pull requests

6 participants