-
Notifications
You must be signed in to change notification settings - Fork 34
/
buildspec.yml
36 lines (34 loc) · 1.38 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- aws ecr get-login-password | docker login --username AWS --password-stdin $REPOSITORY_URI
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Docker build and tagging started on `date`
- docker build -t $REPOSITORY_URI:latest -t $REPOSITORY_URI:$IMAGE_TAG .
- echo Docker build and tagging completed on `date`
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 Update the REPOSITORY_URI:IMAGE_TAG in task definition...
- echo Container image to be used $REPOSITORY_URI:$IMAGE_TAG
- sed -i 's@REPOSITORY_URI@'$REPOSITORY_URI'@g' taskdef.json
- sed -i 's@IMAGE_TAG@'$IMAGE_TAG'@g' taskdef.json
- echo update the REGION in task definition...
- sed -i 's@AWS_REGION@'$AWS_REGION'@g' taskdef.json
- echo update the roles in task definition...
- sed -i 's@TASK_EXECUTION_ARN@'$TASK_EXECUTION_ARN'@g' taskdef.json
artifacts:
files:
- "appspec.yaml"
- "taskdef.json"