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

aws-ecr-assets: skip docker build with parameter #25807

Open
1 of 2 tasks
cjoecker opened this issue Jun 1, 2023 · 3 comments
Open
1 of 2 tasks

aws-ecr-assets: skip docker build with parameter #25807

cjoecker opened this issue Jun 1, 2023 · 3 comments
Labels
@aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@cjoecker
Copy link

cjoecker commented Jun 1, 2023

Describe the feature

I want to be able to skip the docker build with a parameter. Something like this:

import { DockerImageAsset } from "aws-cdk-lib/aws-ecr-assets";

...

new DockerImageAsset(scope, "AppDockerImage", {
    directory: path.join(__dirname, "../"),
    skipBuild: process.env.SKIP_BUILD,
  });

Use Case

Sometimes I just changed something in the infrastructure and want to test the changes without needing to rebuild the docker image since it may take very long. For that, I would like to have a flag in the pipeline that sets an environment variable. That variable can be used to skip the docker build.

Proposed Solution

See feature description

Acknowledgements

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

CDK version used

2.79.1

Environment details (OS name and version, etc.)

macOS

@cjoecker cjoecker added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 1, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets label Jun 1, 2023
@peterwoodworth
Copy link
Contributor

Sounds reasonable that there should be a way to skip this, I don't think there currently is. Thanks for the request!

@peterwoodworth peterwoodworth added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 1, 2023
@joshuabellewDandG
Copy link

const myImage = new DockerImageAsset(scope, "AppDockerImage", {
    directory: path.join(__dirname, "../"),
    skipBuild: process.env.SKIP_BUILD,
  });

const taskDefinition = new ecs.FargateTaskDefinition(this, `${fullServiceName}-container`, {});

taskDefinition.addContainer(`${fullServiceName}-container`, {
    containerName: `${fullServiceName}-container`,
    image: ecs.ContainerImage.fromEcrRepository(ecrRepo, myImage.imageTag),
  });

Yep, I could also do with this feature, but with the above code how would you handle referencing the myImage properties in cdk if the docker image build has been skipped?

I guess this would be a breaking change for anyone that references the properties from the returning object.

@cjoecker
Copy link
Author

@joshuabellewDandG My idea is to skip the build but the "old" image will still exist. That means that you can still reference it if you built it before.

For me, this is not a breaking change. Breaking change for me means, that your current logic may stop working with the new changes. Since this will be a new flag and you will not use it before it exists, your current reason won't stop working.

@pahud pahud added p2 and removed p1 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

4 participants