-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildspec.yml
40 lines (39 loc) · 2.42 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:
- echo Creating notification message file ...
- echo "CODEBUILD_INITIATOR:${CODEBUILD_INITIATOR}" | tee -a sns-message.txt
- echo "CODEBUILD_BUILD_ID:${CODEBUILD_BUILD_ID}" | tee -a sns-message.txt
- echo "CODEBUILD_SOURCE_REPO_URL:${CODEBUILD_SOURCE_REPO_URL}" | tee -a sns-message.txt
- echo "CODEBUILD_SOURCE_VERSION:${CODEBUILD_SOURCE_VERSION}" | tee -a sns-message.txt
- echo "CODEBUILD_RESOLVED_SOURCE_VERSION:${CODEBUILD_RESOLVED_SOURCE_VERSION}" | tee -a sns-message.txt
- echo "DOCKER_COMPOSE_VERSION:${DOCKER_COMPOSE_VERSION}" | tee -a sns-message.txt
- echo Sending notification ...
# - aws sns publish --topic-arn "${SNS_TOPIC_ARN}" --subject "AWS CodeBuild Started - ${CODEBUILD_BUILD_ID}" --message file://sns-message.txt
- echo Logging in to Amazon ECR ... | tee -a log.txt
- $(aws ecr get-login --region us-east-2 --no-include-email)
- ECR_REPO_BASE_URL=368061806057.dkr.ecr.us-east-2.amazonaws.com/appl-tracky
# - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
# - IMAGE_TAG=${COMMIT_HASH:=latest}
# - echo Pulling Docker Images for cache ... | tee -a log.txt
# - docker-compose pull --ignore-pull-failures --parallel 2>&1 | tee -a log.txt
build:
commands:
- echo Building the Docker Compose images ... | tee -a log.txt
- docker-compose build 2>&1 | tee -a log.txt
post_build:
commands:
- echo Pushing the Docker Compose images ... | tee -a log.txt
- docker-compose push 2>&1 | tee -a log.txt
- echo printenv | tee -a log.txt
- printenv | tee -a log.txt
# - echo Sending build log ... | tee -a log.txt
# - aws sns publish --topic-arn "${SNS_TOPIC_ARN}" --subject "AWS CodeBuild Log - ${CODEBUILD_BUILD_ID}" --message fileb://log.txt
- echo "CODEBUILD_BUILD_SUCCEEDING:${CODEBUILD_BUILD_SUCCEEDING}" | tee -a sns-message.txt
# - echo Sending notification ...
# - aws sns publish --topic-arn "${SNS_TOPIC_ARN}" --subject "AWS CodeBuild Completed - ${CODEBUILD_BUILD_ID}" --message file://sns-message.txt
- echo Writing artifact file...
- printf '[{"name":"web", "imageUri":"%s"},{"name":"nginx", "imageUri":"%s"},{"name":"db", "imageUri":"%s"}]' ${ECR_REPO_BASE_URL}/django:latest ${ECR_REPO_BASE_URL}/nginx:latest "postgres:10.5-alpine" > imagedefinitions.json
artifacts:
files: imagedefinitions.json