-
Notifications
You must be signed in to change notification settings - Fork 4k
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
asset staging: do not recurse into the output directory #3899
Comments
This usually happens when you try to build an image from within a directory you want included in the image as well. It creates a recursive path that never ends. |
I had the same problem. The only way to make it work is: |
Thanks Joe. |
This is a bug. It makes sense that when we copy assets into the output directory, we won't descend into the same directory as we copy. |
Saw this issue for a similar use case while using the aws-s3-assets module. I was trying to zip up my cdk project into s3 and use it to bootstrap CodeCommit. Excluding const asset = new Asset(this, 'CodeAsset', {
path: path.join(__dirname, '../'),
exclude: [
'node_modules',
'.git',
'cdk.out'
]
}); |
I added // Create Fargate Service
const fargateService = new ecs_patterns.NetworkLoadBalancedFargateService(
this,
'sample-app',
{
cluster,
taskImageOptions: {
image: ecs.ContainerImage.fromAsset('./') // blows up without cdk.out in .dockerignore
}
}
) |
I bumped into this issue again. It may be stupid but I solved it by making sure that the version of aws-cdk on my machine was the same as on the package.json. I was not bootstrapping it the correct way. |
Don't forget to check your {
"context": {
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true
}
} Otherwise |
You saved me!!! |
Mine seems to ignore my .dockerignore file anyway. Could be because I've changed to context dir but I have also tried adding the .dockerignore file to the root of my context const lith = new lambda.DockerImageFunction(this, `${name}lith`, {
code: lambda.DockerImageCode.fromImageAsset(path.join(__dirname, '../../../../'), { // root of monolith
file: 'packages/deployment-service/Dockerfile', // location of Dockerfile
ignoreMode: IgnoreMode.DOCKER,
exclude: [
'cdk.out',
],
}),
vpc,
}) Tried both ~/.dockerfile and ~/packages/deployment-service/.dockerfile. Not sure what else to try! EditOk so after some investigation: .dockerignore needs to be at the root of the monorepo in my case, in other words: at another editFigured it out. Paths are specified from the asset path. So I needed to be more specific however I'd prefer it if my dockerignore file excluded the cdk dir globally as I specified but hey ho exclude: [
'packages/deployment-service/cdk',
], |
Re: It looks like this is no longer necessary.
|
It looks like this was fixed in #16034. Let us know if anyone is still seeing this issue. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I'm still seeing this issue. I get this when adding the flag, alright. But I still get the
|
Seeing this issue pop up again in random repos :( Figured it out thanks to @bashleigh 's detailed comment! I ignored the entire cdk folder at the root and all was well |
Could you share how you ignored the entire cdk folder at the root? .dockerignore doesn't seem to work as the flag |
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
I am experimenting with polylith monorepo with components, bases, projects that looks similar to this...
My
what worked for me was added |
🐛 Bug Report
What is the problem?
I have hit a corner case with the code related to copy directories. It's going in recursively until Node can no longer handle such long file names.
aws-cdk/packages/@aws-cdk/assets/lib/fs/copy.ts
Lines 7 to 18 in 16eb658
The offending snippet is when I had a docker asset declared as follows:
Running
cdk deploy
showed me this error:(Declaring the directory as its full path did not work neither.)
This is quite a serious issue for me, personally.
A possible solution is to exclude
cdk.out
. I think it's reasonable to assume thatcdk.out
name is reserved for this project.As a temporary workaround for me, I've edited the code so that it looks like the following:
Another possible solution is to avoid recursion if we've already seen the directory in question.
Apparently, it's an issue where the docker build context is the same path as the cdk project.
That said, I'm not sure if the above is enough to reproduce the issue. When I comment the code to create the docker asset, the issue disappears (probably more of a symptom rather than the cause). I've checked if symlinks are the issue (apparently, it's not)
Environment
The text was updated successfully, but these errors were encountered: