aws-cdk: [CDK Pipelines] Asset bundling (running Docker during 'synth') doesn't work
I’m trying out new CDK Pipelines in developer preview. I have a question on how to bundle assets that are using docker container during the build process. Currently during “synth_action”, getting following error:
Reproduction Steps
pipelines.CdkPipeline(self,
"Pipeline",
pipeline_name="Test",
cloud_assembly_artifact=cloud_assembly_artifact,
source_action=codepipeline_actions.CodeCommitSourceAction(
action_name="CodeCommit_Source",
repository=code,
branch="cdkpipeline",
output=source_artifact),
synth_action=pipelines.SimpleSynthAction.standard_npm_synth()
source_artifact=source_artifact,
cloud_assembly_artifact=cloud_assembly_artifact,
build_command="npx cdk synth")
Error Log
stderr: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
at AssetStaging.bundle (/tmp/jsii-kernel-O8ZKbG/node_modules/@aws-cdk/core/lib/asset-staging.js:121:19)
at new AssetStaging (/tmp/jsii-kernel-O8ZKbG/node_modules/@aws-cdk/core/lib/asset-staging.js:38:35)
at new Asset (/tmp/jsii-kernel-O8ZKbG/node_modules/@aws-cdk/aws-s3-assets/lib/asset.js:21:25)
Environment
- CDK CLI Version: 1.51.0
- Module Version: 1.51.0
- Node.js Version: v14.5.0
- OS: OSX Mojave
- Language (Version): Python (3.7.3)
This is 🐛 Bug Report
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 31 (7 by maintainers)
Commits related to this issue
- chore(docs): added troubleshooting entry for Docker error in the synthesis step (#14793) Documents the action the user should take to prevent #9217. The problem here is that, for any app that does... — committed to aws/aws-cdk by otaviomacedo 3 years ago
- chore(docs): added troubleshooting entry for Docker error in the synthesis step (#14793) Documents the action the user should take to prevent #9217. The problem here is that, for any app that does... — committed to hollanddd/aws-cdk by otaviomacedo 3 years ago
- Add esbuild to avoid docker usage in CodeBuild - See https://github.com/aws/aws-cdk/issues/9217#issuecomment-1049685550 — committed to fourTheorem/cross-account-eventbridge by eoinsha 2 years ago
- Add esbuild to avoid docker usage in CodeBuild - See https://github.com/aws/aws-cdk/issues/9217#issuecomment-1049685550 — committed to fourTheorem/cross-account-eventbridge by eoinsha 2 years ago
- Add CDK pipeline (#2) * Add pipeline * Add esbuild to avoid docker usage in CodeBuild - See https://github.com/aws/aws-cdk/issues/9217#issuecomment-1049685550 * Update README with CDK pipeline l... — committed to fourTheorem/cross-account-eventbridge by eoinsha 2 years ago
We worked it out. We ended up doing an npm install of
esbuildlocally in package.json. Apparently if you don’t have it locally, it tries to use docker.Installing
esbuildfixed the issue.Since bundling is a framework feature, We should automatically identify if docker is required for asset bundling and configure your synth environment accordingly.
Ah, I have to add it and deploy before depending on it 😉 – working now.
For those using Python and the CodePipeline object, you can pass
docker_enabled_for_synth=Trueto accomplish this. For example:I resolved this by temporarily removing my lambda that required bundling, allowed the pipeline to update itself, and then added it back in afterwards. I believe this issue is introduced when you create a pipeline without a privileged build server, and then you add something like a Lambda function that requires docker to bundle dependencies. This causes you to end up with a pipeline that gets halted and never updates itself properly.
Hope that helps!
Thank you. I had same issue w/NodeJsFunction but adding esbuild to my dev dependencies fixed the issue.
while this wasn’t specifically relevant to this issue, this is the issue I was taken to when googling for my problem related to the synth action of normal
CodePipelineand this comment helped me solve it. Thanks!I too was having the same issue when deploying a Ruby Lambda function that required extra Gems and the CDK code was written in Python. It uses what @justin8 its just an example if people need it.
The Lambda deployment code is as follows:
You do have to do 1 deployment synth run with only the privileged code included first otherwise it always fails
I’m seeing it during the synth when using the
aws-lambda-pythonpackage. It appears the nodejs one works in a very similar fashion.