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

WIP: Add quarkus CI/CD pipeline #18

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fargate/app_pipeline_cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"app": "npx ts-node --prefer-ts-exts lib/app_pipeline_cdk-stack.ts",
"context": {
"@aws-cdk/core:enableStackNameDuplicates": "true",
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true",
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true
}
}
92 changes: 92 additions & 0 deletions fargate/app_pipeline_cdk/lib/app_pipeline_cdk-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as cdk from '@aws-cdk/core';
import s3 = require('@aws-cdk/aws-s3');
import codecommit = require('@aws-cdk/aws-codecommit');
import codepipeline = require('@aws-cdk/aws-codepipeline');
import codepipeline_actions = require('@aws-cdk/aws-codepipeline-actions');
import codebuild = require('@aws-cdk/aws-codebuild');
import ecr = require('@aws-cdk/aws-ecr')

export class ApplicationPipelineCdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const imageRepository = new ecr.Repository(this, 'ImageRepository', {
imageScanOnPush: true,
repositoryName: 'aws-quarkus-demo'
});

const artifactsBucket = new s3.Bucket(this, "ArtifactsBucket");

const codeRepository = new codecommit.Repository(this, 'CodeRepository', {
repositoryName: 'aws-quarkus-demo-repository'
});

// Pipeline creation starts
const pipeline = new codepipeline.Pipeline(this, 'Pipeline', {
artifactBucket: artifactsBucket,
});

const sourceOutput = new codepipeline.Artifact();

// Add source stage to pipeline
pipeline.addStage({
stageName: 'Source',
actions: [
new codepipeline_actions.CodeCommitSourceAction({
actionName: 'CodeCommit_Source',
repository: codeRepository,
output: sourceOutput
}),
],
});

// Declare build output as artifacts
const buildOutput = new codepipeline.Artifact();

// Declare a new CodeBuild project
const buildProject = new codebuild.PipelineProject(this, 'Build', {
environment: {
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_2,
computeType: codebuild.ComputeType.LARGE,
privileged: true
},
environmentVariables: {
'AWS_ACCOUNT_ID': {
value: process.env.CDK_DEFAULT_ACCOUNT
},
'PACKAGE_BUCKET': {
value: artifactsBucket.bucketName
},
'IMAGE_REPO_NAME': {
value: imageRepository.repositoryName
},
},
buildSpec: codebuild.BuildSpec.fromSourceFilename('fargate/buildspec.yaml')
});

// Add permission to authenticate at push images to the ECR registry
imageRepository.grantPullPush(buildProject.grantPrincipal);

// Add the build stage to our pipeline
pipeline.addStage({
stageName: 'Build',
actions: [
new codepipeline_actions.CodeBuildAction({
actionName: 'Build',
project: buildProject,
input: sourceOutput,
outputs: [buildOutput],
}),
],
});
}
}


const app = new cdk.App();
new ApplicationPipelineCdkStack(app, 'ApplicationPipelineCdkStack', {
env: {
region: "us-east-1",
account: process.env.CDK_DEFAULT_ACCOUNT,
}
});
Loading