Skip to content

Commit d5ff4f2

Browse files
authored
Create buildspec-with-ssm.yml
1 parent 48b3ce6 commit d5ff4f2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

aws-codebuild/buildspec-with-ssm.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 0.2
2+
3+
env:
4+
environment:
5+
aws_region: "eu-west-1"
6+
container_name: "test"
7+
repository_url: "xxxxxxxxxxxx"
8+
parameter-store:
9+
dockerhub_username: "/devops/dev/DOCKERHUB_USERNAME"
10+
dockerhub_password: "/devops/dev/DOCKERHUB_PASSWORD"
11+
12+
phases:
13+
pre_build:
14+
commands:
15+
- echo logging into Dockerhub as upstream not yet using gallery.ecr.aws
16+
- docker login -u $dockerhub_username -p $dockerhub_password
17+
- echo logging into ECR
18+
- $(aws ecr get-login --region $aws_region --no-include-email)
19+
- REPOSITORY_URI=${repository_url}
20+
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
21+
build:
22+
commands:
23+
- echo build started on $(date)
24+
- docker build -t $REPOSITORY_URI:latest .
25+
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
26+
post_build:
27+
commands:
28+
- echo build completed on $(date)
29+
- echo pushing the docker images
30+
- docker push $REPOSITORY_URI:latest
31+
- docker push $REPOSITORY_URI:$IMAGE_TAG
32+
- echo writing image definitions file for deployment
33+
- printf '[{"name":"$container_name","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
34+
35+
artifacts:
36+
files: imagedefinitions.json

0 commit comments

Comments
 (0)