본문 바로가기

SK네트웍스 Family AI캠프 10기/Daily 회고

79일차. AWS - CodePipeline

더보기

 

79일 차 회고.

 

 

 

 

 

 

1. AWS

 

 

1-1. Github

 

CICD/
├─ django-server/
│  ├─ api/
│  │  ├─ migrations/
│  │     └─ __init__.py
│  │  ├─ __init__.py
│  │  ├─ admin.py
│  │  ├─ apps.py
│  │  ├─ models.py
│  │  ├─ tests.py
│  │  ├─ urls.py
│  │  └─ views.py
│  ├─ config/
│  │  ├─ __init__.py
│  │  ├─ asgi.py
│  │  ├─ settings.py
│  │  ├─ urls.py
│  │  └─ wsgi.py
│  ├─ sample/
│  │  ├─ migrations/
│  │     └─ __init__.py
│  │  ├─ __init__.py
│  │  ├─ admin.py
│  │  ├─ apps.py
│  │  ├─ models.py
│  │  ├─ tests.py
│  │  ├─ urls.py
│  │  └─ views.py
│  ├─ static/
│  │  ├─ css/
│  │  │  └─ index.css
│  │  └─ js/
│  │     └─ index.js
│  ├─ templates/
│  │  └─ sample/
│  │     └─ index.html
│  └─ manage.py
├─ nginx-server/
│  └─ default.conf
├─ .gitignore
├─ buildspec.yml
├─ Dockerfile
├─ requirements.txt
└─ run.sh
docker build -t django-project:latest .
docker run --name django-container -d -p 80:80 django-project

 

 

1-2. Amazon ECR

 

ECR(Elastic Container Registry)

  • Docker 이미지를 저장하고 AWS 서비스와 통합하여 배포를 간편하게 해주는 완전관리형 컨테이너 레지스트리

 

Repository 생성

 

 

1-3. AWS CodeBuild

 

CodeBuild

  • 빌드 자동화 도구
  • GitHub에서 코드를 받아 Docker 이미지를 빌드하고 ECR에 업로드한다.

 

Connection 생성

 

Project 생성

 

 

Codebuild Role 권한 추가

 

Image 생성

  • CodeBuild를 통해 이미지가 등록된다.

 

Local 실행

$AWS_DEFAULT_REGION='ap-northeast-2'
$AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text)
$ECR_PASSWORD=$(aws ecr get-login-password --region $AWS_DEFAULT_REGION)

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

docker pull ${Repository URI}
docker run --name django-container -d -p 80:80 ${Repository URI}

 

 

1-4. Amazon ECS

 

ECS(Elastic Container Service)

  • Docker 컨테이너를 자동으로 배포, 관리, 확장할 수 있게 해주는 완전관리형 서비스

 

Cluster 생성

 

Task 생성


  • Role 생성


 

Service 생성

 

Service 접속

  • Security Group - Inbound  rules 추가

  • Service 접속 - Public IP

 

 

1-5. AWS CodePipeline

 

CodePipeline

  • CodeBuild, ECR, ECS를 연결하여 전체 배포 프로세스를 자동화하는 도구

 

Pipeline 생성

 

 

1-6. 삭제

 

  • Security Group
    • Inbound Rule 삭제
  • CodePipeline
    • Pipeline 삭제
  • ECS
    • Service 삭제
    • Task 삭제
    • Cluster 삭제
  • ECR
    • Repository 삭제
  • CodePipeline
    • Project 삭제
    • Build History 삭제
    • Connection 삭제
  • CloudFormation
    • Stack 삭제
  • IAM
    • Role 삭제
    • Policy 삭제
    • Access Key 비활성화
  • CloudWatch
    • Log 삭제