-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildspec.yml
30 lines (29 loc) · 1.23 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
version: 0.2
phases:
pre_build:
on-failure: ABORT
commands:
- echo Logging in to Amazon ECR...
- 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
- echo Login successful
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- export DOCKER_BUILDKIT=1
build:
on-failure: ABORT
commands:
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $REPOSITORY_URI:latest --platform=linux/arm64 .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
- echo Build complete
post_build:
on-failure: ABORT
commands:
- echo Pushing image to Amazon ECR...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Saving image definition
- printf '[{"name":"roast-gpt","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files: imagedefinitions.json