-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
27 lines (24 loc) · 938 Bytes
/
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
version: 0.2
phases:
pre_build:
commands:
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
- docker pull $ECR_REPO_URL:latest
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- docker build --cache-from $ECR_REPO_URL:latest -t $IMAGE_NAME:latest .
- docker tag $IMAGE_NAME:latest $ECR_REPO_URL:latest
- docker tag $IMAGE_NAME:latest $ECR_REPO_URL:$IMAGE_TAG
post_build:
commands:
- docker push $ECR_REPO_URL:latest
- docker push $ECR_REPO_URL:$IMAGE_TAG
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $ECR_REPO_URL:$IMAGE_TAG > imagedefinitions.json
artifacts:
files: imagedefinitions.json
cache:
paths:
- '/root/.npm/**/*'
- 'node_modules/**/*'