1.0.0 • Published 4 years ago
@pahud/cdk-autobuild-patterns v1.0.0
@pahud/cdk-autobuild-patterns
This package helps you build a automated AWS CodeBuild
project with AWS CDK
that builds any public git repository containing the Dockerfile
, tags the image and eventually pushes to a seperate Amazon ECR
repository.
In the example below, we build the Amazon Linux docker image from the Dockerfile
at https://github.com/pahud/amazonlinux-docker-autobuild in the daily basis.
import cdk = require('@aws-cdk/core');
import autobuild = require('@pahud/cdk-autobuild-patterns');
import codebuild = require('@aws-cdk/aws-codebuild');
import events = require('@aws-cdk/aws-events');
const app = new cdk.App();
const env = {
region: app.node.tryGetContext('region') || process.env.CDK_INTEG_REGION || process.env.CDK_DEFAULT_REGION,
account: app.node.tryGetContext('account') || process.env.CDK_INTEG_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT
};
const autoBuild = new autobuild.AutoBuildStack(app, 'AutoBuild', {
env,
source: codebuild.Source.gitHub({
owner: 'pahud',
repo: 'amazonlinux-docker-autobuild'
}),
schedule: events.Schedule.rate(cdk.Duration.days(1)),
repositoryName: 'amazonlinux-autobuild'
})