generated from aws-ia/terraform-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 507
/
buildspec.yml
36 lines (34 loc) · 1.3 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}
- IMAGE_TAG_WITH_ARCH=$IMAGE_TAG-$IMG_SUFFIX_ARCH
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- 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_WITH_ARCH
- docker push $REPO_URL:$IMAGE_TAG_WITH_ARCH
# - echo Preparing spec files in new folder
# - mkdir artifacts
# - cp application-code/nodejs-demoapp/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