-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
executable file
·40 lines (39 loc) · 1.48 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
version: 0.2
phases:
pre_build:
commands:
- git remote set-url origin $REPO_URL
- git fetch origin
- curl $TAG_SCRIPT -o tag-release.sh
- . ./tag-release.sh
- pip3 install awscli --upgrade --user
- echo Logging in to Amazon ECR...
- aws --version
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
- REPOSITORY_URI=$ECR_URL
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=$MAJOR.$MINOR.$PATCH
- if [ "$ENV" -eq "QA" ]; then IMAGE_TAG="${IMAGE_TAG}.snapshot"; fi
build:
commands:
- pip install requests
- echo Build started on `date`
- echo Building the Docker image...
- cd deployment
- docker build -f Dockerfile .. -t $REPOSITORY_URI:latest
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
- git push origin $NEW_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
#- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- cd ..
- printf '[{"name":"user-http","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
- printf '[{"name":"user-grpc","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions-grpc.json
artifacts:
files:
- imagedefinitions.json
- imagedefinitions-grpc.json