-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
22 lines (20 loc) · 972 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
version: 0.2
phases:
pre_build:
commands:
- echo Login to DockerHub...
- docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
build:
commands:
- echo Build Docker image...
- DOCKER_BUILDKIT=1 docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG_BRANCH -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG_REVISION .
post_build:
commands:
- echo Login to 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 Push image to ECR...
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG_BRANCH
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG_REVISION
artifacts:
files:
- template.yml