-
Notifications
You must be signed in to change notification settings - Fork 247
/
buildspec.yml
36 lines (33 loc) · 1.22 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
# AWS CodeBuild buildspec to build the nginx alpine image
# By Jason Umiker (jason.umiker@gmail.com)
# This requires the following environment variables be set on the Project:
# AWS_DEFAULT_REGION (Supplied by CodeBuild)
# AWS_ACCOUNT_ID
# IMAGE_REPO_NAME
# IMAGE_TAG
version: 0.2
phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- CODEBUILD_RESOLVED_SOURCE_VERSION="${CODEBUILD_RESOLVED_SOURCE_VERSION:-$IMAGE_TAG}"
- IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_URI="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG"
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $IMAGE_URI .
post_build:
commands:
- bash -c "if [ /"$CODEBUILD_BUILD_SUCCEEDING/" == /"0/" ]; then exit 1; fi"
- echo Build stage successfully completed on `date`
- echo Pushing the Docker image...
- docker push $IMAGE_URI
- printf '[{"name":"nginx","imageUri":"%s"}]' "$IMAGE_URI" > images.json
artifacts:
files: images.json