-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
30 lines (30 loc) · 1.14 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
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- APP_REPOSITORY_URI=${DOCKER_REPOSITORY}offchain-purchase-service
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- $(aws ecr get-login --no-include-email)
- docker pull $APP_REPOSITORY_URI:latest
build:
on-failure: ABORT
commands:
- echo Build started on `date`
- echo Building the Docker images...
- docker build --build-arg DOCKER_REPOSITORY=$DOCKER_REPOSITORY --cache-from $APP_REPOSITORY_URI:latest -t $APP_REPOSITORY_URI:latest ./
- docker tag $APP_REPOSITORY_URI:latest $APP_REPOSITORY_URI:$IMAGE_TAG
- echo Build completed on `date`
post_build:
on-failure: ABORT
commands:
- echo Pushing the Docker images...
- docker push $APP_REPOSITORY_URI:latest
- docker push $APP_REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"app","imageUri":"%s"}]' $APP_REPOSITORY_URI:$IMAGE_TAG > app-definitios.json
artifacts:
files:
- app-definitios.json