배경
- Github Repository에서 Docker를 빌드하고 AWS ECR에 배포
아키텍처
Github Actions WorkFlow 코드
# This is a basic workflow to help you get started with Actions
name: CD
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: build-image
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2.4.2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SECRET_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} #login-ecr id를 찾음
ECR_REPOSITORY: seear_cicd #레포지토리 명
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . #docker 빌드
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG #docker를 푸시
'Study > Devops' 카테고리의 다른 글
[GCP] Cloud Run과 Cloud Build를 사용하여 Spring Boot 배포하기 (0) | 2022.12.05 |
---|---|
[Docker swarm] 활용해보기 with AWS (0) | 2022.11.24 |
[Continuous Deploy] Github actions .env 파일 관리하기 with Github private repository (0) | 2022.10.14 |
[Continuous Deploy] AWS CodeDeploy & EC2 with Github Actions (0) | 2022.09.17 |
AWS ECS Health-Check (0) | 2022.09.03 |