forked from aws-ia/ecs-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
36 lines (34 loc) · 1.32 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
phases:
pre_build:
commands:
- echo $REPO_URL
- REPOSITORY=${REPO_URL%/*}
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $REPOSITORY
- 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 image...
- sed -i "s|<BACKEND_SVC_ENDPOINT>|$BACKEND_SVC_ENDPOINT|g" application-code/ecsdemo-frontend/Dockerfile
- docker build -t $REPO_URL $FOLDER_PATH
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker tag $REPO_URL $REPO_URL:$IMAGE_TAG
- docker push $REPO_URL:$IMAGE_TAG
- echo Preparing spec files in new folder
- mkdir artifacts
- cp application-code/ecsdemo-frontend/templates/imagedefinition.json artifacts/imagedefinition.json
- echo Preparating artifacts
- sed -i "s|<CONTAINER_NAME>|$CONTAINER_NAME|g" artifacts/imagedefinition.json
- sed -i "s|<REPO_URL>|$REPO_URL:$IMAGE_TAG|g" artifacts/imagedefinition.json
- cat artifacts/imagedefinition.json
artifacts:
files:
- '**/*'
base-directory: 'artifacts'
discard-paths: yes