Skip to content

Commit 6bb89ae

Browse files
add buildspec
1 parent d357271 commit 6bb89ae

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

buildspec/merge_master.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 0.2
2+
phases:
3+
pre_build:
4+
commands:
5+
- echo Logging in to Amazon ECR...
6+
- aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI}
7+
build:
8+
commands:
9+
- echo Building the Docker image...
10+
- docker build -t ${FIPS_REPOSITORY_URI}:latest .
11+
- docker image push --all-tags ${FIPS_REPOSITORY_URI}
12+
post_build:
13+
commands:
14+
- echo Build completed!

buildspec/push.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 0.2
2+
phases:
3+
build:
4+
commands:
5+
- echo Logging in to Amazon ECR...
6+
- aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI}
7+
- export COMMIT_HASH_SHORT="$(echo $COMMIT_HASH | cut -c 1-7)"
8+
- echo Building the Docker image...
9+
- echo $FIPS_REPOSITORY_URI
10+
- echo $COMMIT_HASH_SHORT
11+
- echo $BRANCH_NAME
12+
- docker build --tag ${FIPS_REPOSITORY_URI}:${COMMIT_HASH_SHORT} --tag ${FIPS_REPOSITORY_URI}:${BRANCH_NAME} .
13+
# We have a life cycle policy in place to expire and delete images from dev branches,
14+
# so there are no issues with pushing as many of these images as there may be.
15+
- docker image push --all-tags ${FIPS_REPOSITORY_URI}
16+
post_build:
17+
commands:
18+
- echo Build completed!
19+
- printf '{"tag":"%s"}' $COMMIT_HASH_SHORT > build.json

buildspec/release.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
version: 0.2
3+
phases:
4+
build:
5+
commands:
6+
- echo Logging in to Amazon ECR...
7+
- aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI}
8+
- echo Building the Docker image...
9+
- PATCH_TAG=${TAG_NAME#"v"} # major.minor.patch
10+
- MINOR_TAG=${PATCH_TAG%.*} # major.minor
11+
- MAJOR_TAG=${MINOR_TAG%.*} # major
12+
- docker build -t ${FIPS_REPOSITORY_URI}:${PATCH_TAG} -t ${FIPS_REPOSITORY_URI}:${MINOR_TAG} -t ${FIPS_REPOSITORY_URI}:${MAJOR_TAG} .
13+
- docker image push --all-tags ${FIPS_REPOSITORY_URI}
14+
post_build:
15+
commands:
16+
- echo Build completed!
17+
- printf '{"tag":"%s"}' $TAG_NAME > build.json

0 commit comments

Comments
 (0)