study/devops

๋ฆด๋ฆฌ์ฆˆ์™€ ํ™˜๊ฒฝ๋ณ€์ˆ˜

FYE 2023. 1. 12. 15:00

 

 

๐Ÿ“ chapter ํ™˜๊ฒฝ๋ณ€์ˆ˜

ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ž€ - ๊ฐ๊ธฐ ๋‹ค๋ฅธ ์ปดํ“จํ„ฐ, ์‚ฌ์šฉ์ž๋งˆ๋‹ค ๋ณ„๋„๋กœ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” ๊ณ ์œ ํ•œ ์ •๋ณด๋ฅผ ๋‹ด๋Š”๋ฐ ์‚ฌ์šฉํ•˜๋Š” ๋ณ€์ˆ˜

 

 

์™œ ํ•„์š”ํ•œ๊ฐ€?

  • ๋ฐฐํฌ๋˜๋Š” ๊ธฐ๋Šฅ๋งˆ๋‹ค ์„ค์ •์ด ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—

 

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ • ์˜ˆ

  • ๋ฆฌ๋ˆ…์Šค ์šด์˜์ฒด์ œ : export ๋ช…๋ น์–ด
  • ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ์„ค์ •ํ•˜๋Š” ๋ฒ• : node.js → process.env
  • ์„œ๋น„์Šค ๋‚ด์—์„œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ • : github action

 

 

๐Ÿ“ sprint / ์ฝ”๋“œ๋กœ๋ถ€ํ„ฐ ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๋ถ„๋ฆฌ

 

 

1. Docker ๋นŒ๋“œ์šฉ GitHub Action workflow ๋งŒ๋“ค๊ธฐ

name: Publish Docker image

on:
  release:
    types: [published]

jobs:
  push_to_registry:
    name: Push Docker image to Docker Hub
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v3
      
      - name: Log in to Docker Hub
        uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      
      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
        with:
          images: my-docker-hub-namespace/my-docker-hub-repository
      
      - name: Build and push Docker image
        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

์ฐธ๊ณ  ๋ ˆํผ๋Ÿฐ์Šค

https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-docker-hub

 

Publishing Docker images - GitHub Docs

Introduction This guide shows you how to create a workflow that performs a Docker build, and then publishes Docker images to Docker Hub or GitHub Packages. With a single workflow, you can publish images to a single registry or to multiple registries. Prere

docs.github.com

 

 

 

 

 

2. Release → Create a new release

tag `v.1.0.0`

์ž‘๋™ ์•ˆ๋จ์„ ํ™•์ธ

 

why?

Error : Username and password required

 

 

 

 

3. ์ธ์ฆ ์ •๋ณด ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๋งŒ๋“ค๊ธฐ

`DOCKER_USERNAME` ๋ฐ `DOCKER_PASSWORD`๋ผ๋Š” ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ ์กด์žฌ

 

Settings → Security → Secrets and variables → Actions

์ด๋ ‡๊ฒŒ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์ž‘์„ฑํ•ด์ฃผ๊ธฐ

 

๋ฆด๋ฆฌ์ฆˆ ์„ฑ๊ณต

 

 

 

 

4. Docker repository ํ™•์ธํ•˜๊ธฐ

https://hub.docker.com/u/<my_id>