Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

(@aws-cdk/aws-ecr-assets): DockerImageAsset - support --build-context flag #31598

Copy link
Copy link

Description

@BwL1289
Issue body actions

Describe the feature

We use CDK Pipelines to deploy our infrastructure to dev, staging, and prod accounts.

When we are building dockerfiles using DockerImageAssets, if there are any files/directories the dockerfile needs while being built, we currently have to copy them over any files/directories to the directory where the dockerfile is being built. This is cumbersome and error prone.

Docker now supports (since 2022) the ability to specify multiple build contexts via the --build-context flag.

It would be great to add --build-context to the flags supported here.

Here's an example:

from aws_cdk import aws_ecr_assets as ecr_assets

ecr_docker_image_asset = ecr_assets.DockerImageAsset(
            self,
            "EcrDockerImageAsset",
            directory=<dir>,
            file="Dockerfile",
            build_args=<build_args>,
            build_contexts=["example_build_context_1", "example_build_context_2", ...]
)

Then, we can use the following in the dockerfile like so:

COPY --from=example_build_context_1 ...

Use Case

With --build-context now supported, It's unnecessary to copy any additional files/directories into the build context where you are building your image.

Proposed Solution

Support the --build-context flag.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.158.0

Environment details (OS name and version, etc.)

macOS Sonoma 14.5, AWS CodeBuild

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecr-assetsRelated to AWS CDK Docker Image AssetsRelated to AWS CDK Docker Image Assetseffort/mediumMedium work item – several days of effortMedium work item – several days of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.