-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildspec.yml
More file actions
31 lines (30 loc) · 1.26 KB
/
buildspec.yml
File metadata and controls
31 lines (30 loc) · 1.26 KB
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
version: 0.2
env:
variables:
REPOSITORY_URI: "932200675199.dkr.ecr.ca-central-1.amazonaws.com"
IMAGE_NAME: "inference_container"
AWS_DEFAULT_REGION: ca-central-1
phases:
install:
runtime-versions:
python: latest
pre_build:
commands:
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- GIT_SHA=$COMMIT_HASH
build:
commands:
- echo Build started on `date`
- echo "Pulling components for build"
- aws s3 cp s3://gln-inference-models/p6.pt ./app/
- echo "Building image"
- echo "Pulling Images for cached version in ECR"
- docker pull $REPOSITORY_URI/$IMAGE_NAME:latest || true
- docker build --cache-from $REPOSITORY_URI/$IMAGE_NAME:latest --build-arg GIT_SHA=$GIT_SHA -t $REPOSITORY_URI/$IMAGE_NAME:$IMAGE_TAG -t $REPOSITORY_URI/$IMAGE_NAME:latest -f Dockerfile .
post_build:
commands:
- docker push ${REPOSITORY_URI}/$IMAGE_NAME:latest
- docker tag ${REPOSITORY_URI}/${IMAGE_NAME}:latest ${REPOSITORY_URI}/${IMAGE_NAME}:${IMAGE_TAG}
- docker push ${REPOSITORY_URI}/$IMAGE_NAME:${IMAGE_TAG}