-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildspec_client.yml
37 lines (36 loc) · 1.34 KB
/
buildspec_client.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
version: 0.2
phases:
install:
runtime-versions:
docker: 19
pre_build:
commands:
- echo Logging in to Amazon ECR...
- echo ${DOCKER_PASS} | docker login --username ${DOCKER_USER} --password-stdin
- region=us-west-2
- $(aws ecr get-login --region $region --no-include-email)
- TASK_DEFINITION_FILE=taskdefinition_client.json
- REPOSITORY_URI_API=888507318922.dkr.ecr.us-west-2.amazonaws.com/sample-ecs-app-web-app
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Build started on `date`
- echo Building the Docker images...
- docker build -t sample-app -f ./Dockerfile.client .
- docker tag sample-app $REPOSITORY_URI_API:$IMAGE_TAG
- docker tag sample-app $REPOSITORY_URI_API:latest
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI_API:$IMAGE_TAG
- docker push $REPOSITORY_URI_API:latest
- echo Writing image definitions file...
- printf '[{"name":"aws-community-client","imageUri":"%s"}]' $REPOSITORY_URI_API:$IMAGE_TAG > $TASK_DEFINITION_FILE
- echo `pwd`
- echo `ls -alh`
- echo `cat $TASK_DEFINITION_FILE`
artifacts:
files:
- $TASK_DEFINITION_FILE