-
Notifications
You must be signed in to change notification settings - Fork 3
/
buildspec.yml
36 lines (34 loc) · 1.95 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
version: 0.2
env:
secrets-manager:
DOCKERHUB_ID: arn:aws:secretsmanager:$AWS_DEFAULT_REGION:$AWS_ACCOUNT_ID:secret:dockerhub-login:docker_hub_id
DOCKERHUB_PASS: arn:aws:secretsmanager:$AWS_DEFAULT_REGION:$AWS_ACCOUNT_ID:secret:dockerhub-login:docker_hub_pass
phases:
pre_build:
commands:
- echo "[`date`] Start pre_build --------------------------------------------------------------------------------"
- export REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME
- echo AWS_DEFAULT_REGION = $AWS_DEFAULT_REGION
- echo AWS_ACCOUNT_ID = $AWS_ACCOUNT_ID
- echo IMAGE_REPO_NAME = $IMAGE_REPO_NAME
- echo IMAGE_TAG = $IMAGE_TAG
- echo REPOSITORY_URI = $REPOSITORY_URI
- echo DOCKERHUB_ID = $DOCKERHUB_ID
- echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_ID --password-stdin
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- echo "[`date`] Finish pre_build --------------------------------------------------------------------------------"
build:
commands:
- echo "[`date`] Start build --------------------------------------------------------------------------------"
- docker-compose build
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $REPOSITORY_URI:$IMAGE_TAG
- echo "[`date`] Finish build --------------------------------------------------------------------------------"
post_build:
commands:
- echo "[`date`] Start post_build --------------------------------------------------------------------------------"
- docker push $REPOSITORY_URI:$IMAGE_TAG
- printf '{"Version":"1.0","ImageURI":"%s"}' $REPOSITORY_URI:$IMAGE_TAG > imageDetail.json
- echo "[`date`] Finish post_build --------------------------------------------------------------------------------"
artifacts:
files:
- imageDetail.json