Skip to content

Build fails under Python #58

@SamStephens

Description

@SamStephens

I have a pretty simple project:

        repository = aws_ecr.Repository(
            scope=self,
            id="Repository",
            repository_name="repository-name",
            lifecycle_rules=[
                aws_ecr.LifecycleRule(
                    description="Retain newest 5 images",
                    max_image_count=5,
                )
            ]
        )

        cdk_docker_image_deployment.DockerImageDeployment(
            scope=self,
            id="Deployment",
            source=cdk_docker_image_deployment.Source.directory("docker_images/my_image"),
            destination=cdk_docker_image_deployment.Destination.ecr(
                repository=repository,
                tag="latest",
            ),
        )

However cdk diff fails with the following logs:

$ cdk diff --profile ecor1-dev-admin --require-approval
#1 [internal] load build definition from Dockerfile
#1 sha256:b796e91438eadd7a192cf9d3005c547c32f4ea3bd023121663534be4d279b863
#1 transferring dockerfile: 1.13kB done
#1 DONE 0.1s

#2 [internal] load .dockerignore
#2 sha256:1c3c187a874bea6aca67fcb2a6cc71d790432a8fbad3a85943427c4216396d53
#2 transferring context:
#2 transferring context: 2B done
#2 DONE 0.1s

#3 [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest
#3 sha256:f2d037379d4f299b26297d7bf04afed72266cfbe5f50259424c51dc48586f328
#3 DONE 1.1s

#12 [1/9] FROM public.ecr.aws/sam/build-nodejs16.x@sha256:83e95e9829d3ea82caba87a2c5ac22e968554127084759eaa8c7a1c3dfc903a3
#12 sha256:09519ac179bf83b86f9548fce8da22ec3fdd58130aea50cf69fcdff1c69372ee
#12 DONE 0.0s

#5 [3/9] RUN npm install --global pnpm
#5 sha256:4d40ae4106cf7a293fea76ebcfc292677617ea41eb8341ae869ad166257198cc
#5 CACHED

#8 [6/9] RUN mkdir /tmp/npm-cache &&     chmod -R 777 /tmp/npm-cache &&     npm config --global set cache /tmp/npm-cache
#8 sha256:8b169b3423314bd97b6c8301babb4e102396485960a6d31311c9768303a79906
#8 CACHED

#7 [5/9] RUN npm install --global --unsafe-perm=true esbuild@0
#7 sha256:62798f8084b6db368dd9ffc5e5a46666aeb33d20b7145933aad7c8faad999d2f
#7 CACHED

#4 [2/9] RUN npm install --global [email protected]
#4 sha256:31b533433625bec5fab274ba34677b62e139f5843dddbd66f228894ef5b1a665
#4 CACHED

#6 [4/9] RUN npm install --global typescript
#6 sha256:cd8966936608ef39d8f0cbc177d61155f43ff589c73fea42510c519718f469d3
#6 CACHED

#9 [7/9] RUN mkdir /tmp/yarn-cache &&     chmod -R 777 /tmp/yarn-cache &&     yarn config set cache-folder /tmp/yarn-cache
#9 sha256:a6edbf2e128b51be571dbac450713e02ab6ad39cce88303d335e482e608a988a
#9 CACHED

#10 [8/9] RUN npm config --global set update-notifier false
#10 sha256:5c4225a29894316982444a7b47192590f5943d0f87adda8a2f69d69adbad1267
#10 CACHED

#11 [9/9] RUN /sbin/useradd -u 1000 user && chmod 711 /
#11 sha256:c9101066662756f7c263dae011a143af6023e04d0e245431d38af010f3faf695
#11 CACHED

#13 exporting to image
#13 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#13 exporting layers done
#13 writing image sha256:573a571f4ea02ff26a7286363564c1ff6312d20964cf161499812e2aca605afd done
#13 naming to docker.io/library/cdk-dd77f71a59e8dcfe24e40e4b37756150510214e9121cf2adf253e4f3f99c9648 done
#13 DONE 0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Bundling asset LibreofficeImageStack/LibreofficeImageDeployment/onEventHandler/Code/Stage...
esbuild cannot run locally. Switching to Docker bundling.
✘ [ERROR] Could not resolve "/tmp/jsii-kernel-ikJV9l/node_modules/cdk-docker-image-deployment/lib/codebuild-handler/index.js"

1 error
jsii.errors.JavaScriptError:
  Error: Failed to bundle asset LibreofficeImageStack/LibreofficeImageDeployment/onEventHandler/Code/Stage, bundle output is located at /home/sam/EcoR1/libreoffice-image/cdk.out/bundling-temp-4bb4262ec4e18eaa157c024d8275ccc92eb62580381dd5ddb595bc7804502d69-error: Error: docker exited with status 1
      at AssetStaging.bundle (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:614)
      at AssetStaging.stageByBundling (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:4506)
      at stageThisAsset (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:1867)
      at Cache.obtain (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
      at new AssetStaging (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2262)
      at new Asset (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:736)
      at AssetCode.bind (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4628)
      at new Function (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:2803)
      at new NodejsFunction (/tmp/jsii-kernel-ikJV9l/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1171)
      at new DockerImageDeployment (/tmp/jsii-kernel-ikJV9l/node_modules/cdk-docker-image-deployment/lib/docker-image-deployment.js:55:32)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/sam/EcoR1/libreoffice-image/app.py", line 9, in <module>
    LibreofficeImageStack(
  File "/home/sam/.pyenv/versions/libreoffice-image-3.9.7/lib/python3.9/site-packages/jsii/_runtime.py", line 100, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/home/sam/EcoR1/libreoffice-image/cdk/libreoffice_image_stack.py", line 30, in __init__
    cdk_docker_image_deployment.DockerImageDeployment(
  File "/home/sam/.pyenv/versions/libreoffice-image-3.9.7/lib/python3.9/site-packages/jsii/_runtime.py", line 100, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/home/sam/.pyenv/versions/libreoffice-image-3.9.7/lib/python3.9/site-packages/cdk_docker_image_deployment/__init__.py", line 245, in __init__
    jsii.create(self.__class__, self, [scope, id, props])
  File "/home/sam/.pyenv/versions/libreoffice-image-3.9.7/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 321, in create
    response = self.provider.create(
  File "/home/sam/.pyenv/versions/libreoffice-image-3.9.7/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 347, in create
    return self._process.send(request, CreateResponse)
  File "/home/sam/.pyenv/versions/libreoffice-image-3.9.7/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 329, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Failed to bundle asset LibreofficeImageStack/LibreofficeImageDeployment/onEventHandler/Code/Stage, bundle output is located at /home/sam/EcoR1/libreoffice-image/cdk.out/bundling-temp-4bb4262ec4e18eaa157c024d8275ccc92eb62580381dd5ddb595bc7804502d69-error: Error: docker exited with status 1

I'm running Ubuntu on WSL 2, Python 3.9.7, CDK 2.46.0, NodeJS 16.15.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions