-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yaml
30 lines (29 loc) · 1.23 KB
/
buildspec.yaml
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:
# output version
- echo app $APP_ID
- echo source version $CODEBUILD_SOURCE_VERSION
- echo build number $CODEBUILD_BUILD_NUMBER
# 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
build:
on-failure: ABORT
commands:
# Building the "production" Docker image
- docker build --target production -t $IMAGE_REPO_NAME:$IMAGE_TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
# Pushing the Docker image to your ECR
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
on-failure: ABORT
commands:
# Prep template
- docker build --target build -t $APP_ID.build:v$CODEBUILD_BUILD_NUMBER .
- docker run --name $APP_ID$CODEBUILD_BUILD_NUMBER $APP_ID.build:v$CODEBUILD_BUILD_NUMBER
- docker cp $APP_ID$CODEBUILD_BUILD_NUMBER:/app/cdk/template-export.yml .
artifacts:
files:
- template-export.yml