.gitlab.yml)
에서
Build and Push
stage를 정의했었다.
새로운 브랜치를 만들고 .gitlab.yml
을 수정해보자.
git checkout -b feature/build-push-pipeline
Build and Push:
stage: Build and Push
script:
- echo "Build and Push Docker Image"
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'
Build and Push:
image: docker:20.10.0
services:
- docker:20.10.0-dind
stage: Build and Push
script:
- apk add python3 py-pip
- pip3 install awscli==1.18.8
- docker build --compress -t $ECR_REPO:$CI_COMMIT_SHORT_SHA .
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker push $ECR_REPO:$CI_COMMIT_SHORT_SHA
- docker tag $ECR_REPO:$CI_COMMIT_SHORT_SHA $ECR_REPO:latest
- docker push $ECR_REPO:latest
rules:
- if: '$CI_COMMIT_BRANCH =~ /^(master|production)$/'