Skip to content

cloudtype-examples/webinar-02

Repository files navigation



Cloudtype



클라우드타입 웨비나 #02
GitHub Actions, Private Registry를 활용한
CI/CD 파이프라인 구축하기

목차

🛠️ 준비사항

🗄️ Private Registry

AWS Elastic Registry

토큰 생성 명령어

  • AWS CLI 설치

      curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
      sudo installer -pkg AWSCLIV2.pkg -target /
  • AWS 계정 설정

      aws configure
  • AWS 토큰 발급

      aws ecr get-login-password --region ap-northeast-2
    

GitHub Repository Secrets

  • AWS_ECR_REGISTRY: AWS ECR Registry 주소(리포지토리 경로 제외)
  • AWS_ACCESS_KEY_ID: AWS 액세스 키 ID
  • AWS_SECRET_ACCESS_KEY: AWS 시크릿 액세스 키
  • CLOUDTYPE_TOKEN: 클라우드타입 API 키

GitHub Actions Workflow

name: Create and publish a Docker image to AWS ECR, Deploy to Cloudtype

on:
  push:
    branches:
      - main

env:
  REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }}
  IMAGE_NAME: [이미지명]

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Log in to the Container registry
        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.AWS_ACCESS_KEY_ID }}
          password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=sha
      - name: Build and push Docker image
        uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

      - name: Deploy to Cloudtype
        uses: cloudtype-github-actions/deploy@v1
        with:
          token: ${{ secrets.CLOUDTYPE_TOKEN }}
          project: [스페이스명]/[프로젝트명]
          stage: main
          yaml: |
            name: [서비스명]
            app: container
            options:
              ports: [포트번호]
              image: ${{ steps.meta.outputs.tags }}

GCP Artifact Registry

GitHub Repository Secrets

  • GAR_REGISTRY: Artifact Registry 주소
  • GAR_JSON_KEY: Artifact Registry 서비스 계정 JSON KEY
  • CLOUDTYPE_TOKEN: 클라우드타입 API 키

GitHub Actions Workflow

name: Create and publish a Docker image to GCP Artifact Registry, Deploy to Cloudtype

on:
  push:
    branches:
      - main

env:
  REGISTRY: ${{ secrets.GAR_REGISTRY }}
  IMAGE_NAME: [이미지명]

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      
      - name: Log in to the Container registry
        uses: docker/login-action@v2
        with:
          registry: ${{ env.REGISTRY }}
          username: _json_key
          password: ${{ secrets.GAR_JSON_KEY }}
          
      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=sha
      - name: Build and push Docker image
        uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

      - name: Deploy to Cloudtype
        uses: cloudtype-github-actions/deploy@v1
        with:
          token: ${{ secrets.CLOUDTYPE_TOKEN }}
          project: [스페이스명]/[프로젝트명]
          stage: main
          yaml: |
            name: [서비스명]
            app: container
            options:
              ports: [포트번호]
              image: ${{ steps.meta.outputs.tags }}

📖 References

💬 Contact

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published