generated from aws-ia/terraform-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 507
/
buildspec_manifest.yml
41 lines (40 loc) · 1.57 KB
/
buildspec_manifest.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
38
39
40
41
version: 0.2
# Based on the Docker documentation, must include the DOCKER_CLI_EXPERIMENTAL environment variable
# https://docs.docker.com/engine/reference/commandline/manifest/
phases:
install:
commands:
- yum update -y
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 $REPO_URL:$IMAGE_TAG
- echo Building the Docker manifest...
- export DOCKER_CLI_EXPERIMENTAL=enabled
- docker manifest create $REPO_URL:$IMAGE_TAG $REPO_URL:$IMAGE_TAG-arm64v8 $REPO_URL:$IMAGE_TAG-amd64
- 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
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker manifest...
- docker manifest push $REPO_URL:$IMAGE_TAG
- docker manifest inspect $REPO_URL:$IMAGE_TAG
artifacts:
files:
- '**/*'
base-directory: 'artifacts'
discard-paths: yes