https://github.com/cdklabs/cdk-docker-image-deployment
https://github.com/cdklabs/cdk-docker-image-deployment
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cdklabs/cdk-docker-image-deployment
- Owner: cdklabs
- License: apache-2.0
- Created: 2022-08-04T19:05:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-03-26T00:44:01.000Z (3 months ago)
- Last Synced: 2026-03-26T22:51:32.602Z (3 months ago)
- Language: TypeScript
- Size: 4.09 MB
- Stars: 87
- Watchers: 13
- Forks: 15
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Notice: NOTICE
Awesome Lists containing this project
README
## CDK Docker Image Deployment
This module allows you to copy docker image assets to a repository you control.
This can be necessary if you want to build a Docker image in one CDK app and consume it in a different app or outside the CDK,
or if you want to apply a lifecycle policy to all images of a part of your application.
### Getting Started
Below is a basic example for how to use the `DockerImageDeployment` API:
```ts
import * as ecr from 'aws-cdk-lib/aws-ecr';
import * as imagedeploy from 'cdk-docker-image-deployment';
const repo = ecr.Repository.fromRepositoryName(this, 'MyRepository', 'myrepository');
new imagedeploy.DockerImageDeployment(this, 'ExampleImageDeploymentWithTag', {
source: imagedeploy.Source.directory('path/to/directory'),
destination: imagedeploy.Destination.ecr(repo, {
tag: 'myspecialtag',
}),
});
```
### Currently Supported Sources
- `Source.directory()`: Supply a path to a local docker image as source.
> Don't see a source listed? See if there is an open [issue](https://github.com/cdklabs/cdk-docker-image-deployment/issues)
> or [PR](https://github.com/cdklabs/cdk-docker-image-deployment/pulls) already. If not, please open an issue asking for it
> or better yet, submit a contribution!
### Currently Supported Destinations
- `Destination.ecr(repo, options)`: Send your docker image to an ECR repository in your stack's account.
> Don't see a destination listed? See if there is an open [issue](https://github.com/cdklabs/cdk-docker-image-deployment/issues)
> or [PR](https://github.com/cdklabs/cdk-docker-image-deployment/pulls) already. If not, please open an issue asking for it
> or better yet, submit a contribution!
### Under the Hood
1. When this stack is deployed (either via cdk deploy or via CI/CD), the contents of the local Docker image will be archived and uploaded to an intermediary assets ECR Repository using the cdk-assets mechanism.
2. The `DockerImageDeployment` construct synthesizes a CodeBuild Project which uses docker to pull the image from the intermediary repository, tag the image if a tag is provided, and push the image to the destination repository.
3. The deployment will wait until the CodeBuild Project completes successfully before finishing.
The architecture of this construct can be seen here:

## Security
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
## License
This project is licensed under the Apache-2.0 License.