Skip to content

๐Ÿš€ CICD ๊ตฌ์กฐ ์ˆ˜์ •

Kang Chaeryeon edited this page Nov 19, 2024 · 1 revision

๊ตฌ์กฐ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ์ด์œ 

์ €์žฅ ๊ณต๊ฐ„ ๋ฐ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋ถ€์กฑํ•œ ๊ธฐ์กด ncloud ์„œ๋ฒ„์—์„œ
์›น ์„œ๋ฒ„๋ฅผ ๋Œ๋ฆฌ๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ถˆํ•„์š”ํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ์ค„์—ฌ์•ผ ํ–ˆ๋‹ค.

๊ธฐ์กด์—๋Š” GitHub Actions์—์„œ ncloud ์„œ๋ฒ„์— ์ ‘๊ทผํ•˜์—ฌ,
์ €์žฅ๋œ git local storage์—์„œ git pull ์„ ์ง„ํ–‰ํ–ˆ๋‹ค.
์ดํ›„์— ํ”„๋กœ์ ํŠธ๋ฅผ ๋„์ปค ํŒŒ์ผ๋กœ ๋นŒ๋“œ ๋ฐ ์‹คํ–‰ํ•œ๋‹ค.

ํ•˜์ง€๋งŒ, ๋„์ปค ํŒŒ์ผ์˜ ์žฅ์ ์€ ์ด๋ฏธ์ง€๋งŒ ๊ฐ€์ง€๊ณ  ์–ด๋Š ํ™˜๊ฒฝ์—์„œ๋‚˜ ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด๊ณ ,
์ด์ „๊นŒ์ง€ ๊ทธ ์žฅ์ ์„ ํ™œ์šฉํ•˜์ง€ ๋ชปํ•˜๋‹ค๊ณ  ์ƒ๊ฐ๋˜์–ด ๊ตฌ์กฐ๋ฅผ ์ˆ˜์ •ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

์ˆ˜์ • ๋ฐฉ์•ˆ

์šฐ์„  ๋„์ปค ์ด๋ฏธ์ง€๋กœ ๋นŒ๋“œํ•˜๋Š” ์—ญํ• ์„ GitHub Actions์— ๋ถ„๋ฐฐํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

  • ์ด๋ ‡๊ฒŒ ๋  ๊ฒฝ์šฐ ncloud ์„œ๋ฒ„์— github ํ”„๋กœ์ ํŠธ ํŒŒ์ผ์„ ์ €์žฅํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

์œ„์™€๊ฐ™์ด ํ–ˆ์„ ๋•Œ, GitHub Actions์—์„œ๋Š” ํ”„๋กœ์ ํŠธ๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ docker ์ด๋ฏธ์ง€๋กœ ๋นŒ๋“œํ•˜๊ณ ,
Docker Hub์— pushํ•˜๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค.

ncloud ์„œ๋ฒ„์—์„œ๋Š” Docker Hub์—์„œ ์ตœ์‹  ์ด๋ฏธ์ง€๋ฅผ pullํ•˜๊ณ  ์ €์žฅ๋œ compose ํŒŒ์ผ์„ ์‹คํ–‰์‹œ์ผœ์•ผ ํ•œ๋‹ค.

  • ๋ชจ๋…ธ๋ ˆํฌ๊ธฐ ๋•Œ๋ฌธ์— ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ ๋‘ ์ด๋ฏธ์ง€๋กœ ๊ตฌ์„ฑ์ด ๋˜์–ด์žˆ๋‹ค.
  • ๋‘ ์ด๋ฏธ์ง€๋ฅผ ํ•จ๊ป˜ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด compose๋กœ ๊ด€๋ฆฌ๋˜๊ณ  ์žˆ๋‹ค.

๋ฌธ์ œ ํ•ด๊ฒฐ ๊ณผ์ •

์ด๋ฏธ์ง€๋ฅผ ์–ด๋–ป๊ฒŒ ์˜ฌ๋ฆฌ์ง€?

Docker Hub์— Docker Image ์˜ฌ๋ฆฌ๊ธฐ

๋ฐฑ์—”๋“œ ์„œ๋ฒ„๊ฐ€ ์•„ํŒŒํ•œ๋‹ค

์œ„ ์‚ฌ์ง„์€๋„์ปค compose ํŒŒ์ผ์„ ์‹คํ–‰์‹œํ‚ค๊ณ  ๋œฌ ๋กœ๊ทธ์ด๋‹ค.
์ด ๋กœ๊ทธ์—์„œ 6379 ํฌํŠธ์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒƒ์„ ๋ณด๊ณ  redis ์—ฐ๊ฒฐ์ด ์•ˆ๋˜์–ด์žˆ๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

redis ์—ฐ๊ฒฐ์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” .env ์„ค์ •์ด ํ•„์š”ํ–ˆ๋‹ค.
๊นƒํ—ˆ๋ธŒ ์ €์žฅ์†Œ์—๋Š” .env ํŒŒ์ผ์ด ๋“ค์–ด๊ฐ€์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ์„œ๋ฒ„์— .env ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ ,
๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ด๋ฏธ์ง€๊ฐ€ .env ํŒŒ์ผ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

๊ฒ€์ƒ‰ํ•ด๋ณธ ๊ฒฐ๊ณผ, env_file ์ด๋ผ๋Š” ์˜ต์…˜์„ ํ†ตํ•ด์„œ .env ํŒŒ์ผ์„ ๋งคํ•‘์‹œ์ผœ์ค„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
๊ทธ๋ ‡๊ฒŒ ncloud ์„œ๋ฒ„์— server.env์™€ client.env ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ ,
๊ฐ ์ด๋ฏธ์ง€์— ๋งž๊ฒŒ .env ํŒŒ์ผ์„ ๊ฐ€์ง€๋„๋ก ์„ค์ •ํ–ˆ๋‹ค.

  server-green:
    image: "rdyjun/inear-server:latest"
    container_name: server-green
    expose:
      - '3000'
    env_file:
      - ./server.env        # ์ด ๋ถ€๋ถ„ 
    environment:
      - NODE_ENV=development
    networks:
      - webapp
    # healthcheck ์ž„์‹œ ์ œ๊ฑฐ
    restart: unless-stopped
  client:
    image: "rdyjun/inear-client:latest"
    container_name: client
    expose:
      - '5173'
    env_file:
      - ./client.env        # ์ด ๋ถ€๋ถ„
    environment:
      - NODE_ENV=development
    networks:
      - webapp
    restart: unless-stopped

์œ„ ์„ค์ •์„ ํ†ตํ•œ ๊ฒฐ๊ณผ๋Š”โ€ฆ

ํšจ๊ณผ๋Š” ๋Œ€๋‹จํ–ˆ๋‹ค!

image

redis ์—ฐ๊ฒฐ์ด ์ž˜ ์ด๋ฃจ์–ด์ ธ ์„œ๋ฒ„๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜์—ˆ๋‹ค.

์›น์ด ์•ˆ๋ณด์ธ๋‹ค!

image image

์œ„ ์ •๋ณด์™€ ๊ฐ™์ด ์„œ๋ฒ„๊ฐ€ ์ œ๋Œ€๋กœ ์‹คํ–‰๋˜๊ณ  ์žˆ์Œ์—๋„ ์‹ค์ œ ์„œ๋ฒ„์— ์ ‘์†์ด ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.
์ž์„ธํžˆ ๋ณด๋‹ˆ, react-router-dom ์ด ์ œ๋Œ€๋กœ ์„ค์น˜๋˜์ง€ ์•Š์€ ๋ฌธ์ œ๋กœ ๋ณด์ธ๋‹ค.
์ƒ๊ฐํ•ด๋ณด๋‹ˆ, ์–ด์ œ(24.11.15) ์ด ๋ฌธ์ œ๋ฅผ ๊ฒช์—ˆ๊ณ , ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ๋ธŒ๋žœ์น˜๋ฅผ mergeํ–ˆ๋‹ค.
๊ทธ๋ž˜์„œ ์ด ๋ฌธ์ œ์— ๋Œ€ํ•ด์„œ๋Š” dev ๋ธŒ๋žœ์น˜๋ฅผ merge ํ•˜๊ณ  ๋‹ค์‹œ ํ•ด๋ณด๋ฉด ๊ดœ์ฐฎ์•„์งˆ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

๊ทธ๋ž˜์„œ.. ๋์–ด?

image

์•„๊นŒ ์žˆ์—ˆ๋˜ ์˜ค๋ฅ˜๋Š” ์—†์–ด์กŒ๋‹ค.
์ง€๊ธˆ ๋ณด์ด๋Š” ํ™”๋ฉด์—์„œ๋Š” ๋ฌธ์ œ์—†์ด nginx, react, nest๊ฐ€ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.
์ด๋•Œ ๋‹น์‹œ์—๋Š” ์›น ๋ธŒ๋ผ์šฐ์ € ์ ‘๊ทผ์ด ๋  ์ค„ ์•Œ์•˜๋‹คโ€ฆ

ํ•˜์ง€๋งŒ ์–ด๊น€์—†์ด cloudflare์˜ Error ํŽ˜์ด์ง€๋งŒ ๋ณด์˜€๋‹ค.. image

์›์ธ์ด ๋ญ˜๊นŒ๋ฅผ ๊ณ ๋ฏผํ•ด๋ดค๋‹ค.

  • server ๋˜๋Š” client ํ”„๋กœ์ ํŠธ๊ฐ€ ์ž˜๋ชป๋๋‹ค
    • ์ด๊ฑด ๋‚ด๊ฐ€ ๋ณด๊ธฐ์—” ์•„๋‹ˆ์—ˆ๋‹ค.
    • ๋กœ๊ทธ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ถœ๋ ฅ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
  • ๋ฐฉํ™”๋ฒฝ?
    • ๋ฐฐํฌ ๋ฐฉ์‹์„ ๋ฐ”๊พธ๊ธฐ ์ „์—๋Š” ์ž˜ ์ ‘์†๋๋˜ ๊ฒƒ์„ ์ƒ๊ฐํ•ด๋ณด๋ฉด, ๋ฐฉํ™”๋ฒฝ์€ ์›์ธ์ด ์•„๋‹ˆ๋‹ค.
  • ๊ทธ๋Ÿผ nginx๊ฐ€ ๋ฌธ์ œ์ธ๊ฐ€?
    • ๊ทธ๋ ‡๋‹ค. nginx๊ฐ€ ๋ฌธ์ œ์˜€๋‹ค.

nginx ์ด๋ฏธ์ง€๋Š” ๋ญ๊ฐ€ ๋ฌธ์ œ์ผ๊นŒ?

๊ฐ€์žฅ ๋จผ์ € ์ด ๋ฌธ์ œ๋ฅผ ์ดํ•ดํ•  ์ˆ˜ ์—†์–ด์„œ GPT์—๊ฒŒ ์งˆ๋ฌธํ–ˆ๋‹ค.
docker ps ๊ฒฐ๊ณผ๋ฅผ ์ฃผ๊ณ  ๋ฌธ์ œ๋ฅผ ์ฐพ์•„๋‹ฌ๋ผ๊ณ  ํ–ˆ๋”๋‹ˆ,

CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS         PORTS                NAMES
5f3f397d0de4   rdyjun/inear-nginx:latest    "/docker-entrypoint.โ€ฆ"   5 seconds ago    Up 4 seconds   0.0.0.0:80->80/tcp   nginx
24dd46260274   rdyjun/inear-server:latest   "docker-entrypoint.sโ€ฆ"   5 seconds ago    Up 4 seconds   3000/tcp             server-green
4c464b8d4863   rdyjun/inear-client:latest   "docker-entrypoint.sโ€ฆ"   37 minutes ago   Up 4 seconds   5173/tcp             client

์œ„ ๋ฌธ์žฅ์—์„œ PORTS๋ฅผ ๋ณด๊ณ  ํ˜ธ์ŠคํŠธ์— ๋…ธ์ถœ๋˜์ง€ ์•Š์€ ์ƒํƒœ๋ผ๊ณ  ํ–ˆ๋‹ค.

๊ทธ๋ฆฌํ•˜์—ฌ docker-compose.yml ํŒŒ์ผ์— expose๋ฅผ ์ง€์šฐ๊ณ  ports: 3000:3000๊ณผ ports: 5173:5173์„ ์ถ”๊ฐ€ํ–ˆ๋‹ค.

์—ฌ์ „ํžˆ ์ž‘๋™ํ•˜์ง€ ์•Š์•˜๋‹ค.

์ด ๋ถ€๋ถ„์— ์žˆ์–ด์„œ๋Š” ๋ฐฐํฌ ๋ฐฉ์‹์„ ์ˆ˜์ •ํ•˜๊ธฐ ์ „์—๋„ ์ด ๋ฐฉ์‹์œผ๋กœ ๋ฐฐํฌํ–ˆ์—ˆ๊ธฐ์—, ๊ดœ์ฐฎ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๊ณ  ๋‹ค์‹œ ๋Œ๋ ค ๋‘์—ˆ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ๋„๋Œ€์ฒด ๋ญ๊ฐ€ ๋ฌธ์ œ์ง€?

์ด๋Ÿฐ์ €๋Ÿฐ ์ž‘์—…์„ ํ•ด๋ณด๋ ค๊ณ  ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋˜ ์ค‘์— ls๋ฅผ ์ž…๋ ฅํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ, ์›๋ž˜ ์—†์—ˆ๋˜ nginx ํŒŒ์ผ์ด ์ƒ๊ฒผ๋˜ ๊ฒƒ์ด๋‹ค.
๊ทธ๋ ‡๊ฒŒ ์›๋ž˜ ์ €์žฅ์†Œ์— ๊ธฐ๋กํ•œ nginx ํŒŒ์ผ์„ ๋ฎ์–ด์”Œ์›Œ๋ณด๋ฉด ์–ด๋–จ๊นŒ๋ผ๋Š” ์ƒ๊ฐ์„ ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

๊ฒฐ๊ณผ์ ์œผ๋กœ๋Š”โ€ฆ ์„ฑ๊ณตํ–ˆ๋‹ค..!

Dockerfile ๋‚ด๋ถ€์— COPY nginx.conf๋งŒ ์ž‘์„ฑ๋˜์–ด์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค.

FROM nginx:alpine

COPY nginx.conf

nginx.conf๋Š” ์ด๋ฏธ์ง€์—์„œ ๊ฐ€์ง€๊ณ  ์žˆ์ง€๋งŒ, conf.d/default.conf ๊ฐ€ ๋ˆ„๋ฝ๋˜์–ด ๊ทธ๋Ÿฐ ๋ฌธ์ œ์˜€๋‹ค.

docker compose๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ ์•„๋ž˜์™€ ๊ฐ™์ด ๋กœ์ปฌ์˜ ./nginx/conf.d๋ฅผ ์ด๋ฏธ์ง€์— ๊ฐ€์ ธ์™€, /etc/nginx/conf.d:ro ์™€ ๊ฐ™์ด ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

volumes:
  - ./nginx/conf.d:/etc/nginx/conf.d:ro

์ด๋Ÿฌํ•œ ์›์ธ์œผ๋กœ test ๋””๋ ‰ํ† ๋ฆฌ์— nginx ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์•˜๊ณ , /etc/nginx/conf.d/default.conf ๊ฐ€ ์ดˆ๊ธฐํ™”๋˜์–ด ์ œ๋Œ€๋กœ nginx๊ฐ€ ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•˜์ง€ ๋ชปํ–ˆ๋˜ ๊ฒƒ์ด๋‹ค.

์ด ๋‚ด์šฉ์— ๋Œ€ํ•œ ์ฆ๋ช…์€, ๊ธฐ์กด nginx/conf.d/default.conf ํŒŒ์ผ์„ ๊ทธ๋Œ€๋กœ test ๋””๋ ‰ํ† ๋ฆฌ๋กœ ๋ณต์‚ฌํ•˜๊ณ ,

docker compose๋ฅผ ์‹คํ–‰์‹œํ‚จ ๊ฒฐ๊ณผ๋กœ ๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

๊ฒฐ๊ณผ๋Š” ์ œ๋Œ€๋กœ ํŽ˜์ด์ง€๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋˜์—ˆ๋‹ค.

์ด๋Ÿฌ๋ฉด ๋˜ ๊ณ ๋ฏผํ•ด์•ผ ํ•  ๊ฒŒ ์žˆ์„ํ…๋ฐ..

๋ฌด์ค‘๋‹จ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด์„œ ์„œ๋ฒ„ ์ด๋ฏธ์ง€๋Š” ๊ทธ๋ฆฐ/๋ธ”๋ฃจ ๋ฐฐํฌ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ ํด๋ผ์ด์–ธํŠธ๋Š”? ํด๋ผ์ด์–ธํŠธ๋„ ๋˜‘๊ฐ™์ด ๊ทธ๋ฆฐ/๋ธ”๋ฃจ ๋ฐฐํฌ ๋ฐฉ์‹์ฒ˜๋Ÿผ
5173/5174๋กœ ๋‚˜๋ˆ„์–ด์„œ ๋ฐฐํฌํ•ด์•ผ ํ•œ๋‹ค.

๋ฌผ๋ก  ํด๋ผ์ด์–ธํŠธ ํŠน์„ฑ์ƒ ๊ผญ ๊ทธ๋ฆฐ/๋ธ”๋ฃจ๋กœ ๋‚˜๋ˆ„์ง€ ์•Š์•„๋„ ๋œ๋‹ค.
GitHub Actions์—์„œ buildํ•œ ํด๋ผ์ด์–ธํŠธ ํŒŒ์ผ์„ ์„œ๋ฒ„๋กœ ๋ณต์‚ฌํ•˜๊ณ ,
ํ•ด๋‹น ํŒŒ์ผ์ด nginx์—์„œ ์ •์  ํŒŒ์ผ๋กœ ์‚ฌ์šฉ๋˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.
๋‹ค๋งŒ, ์ด ๋ฐฉ์‹์„ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ์˜ ๋ฌธ์ œ์ ์€ ๋ฒ„์ „๊ด€๋ฆฌ๊ฐ€ ์–ด๋ ต๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

์šฐ์„ ์€ ๊ฐ€๋Šฅํ•œ ์ปค๋ฐ‹ ๋ฒ„์ „์— ๋งž์ถ”์–ด ๋กค๋ฐฑํ•  ์ˆ˜ ์žˆ๋„๋ก
ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ์ ํŠธ ํŒŒ์ผ๋„ 5173 / 5174๋กœ ํฌํŠธ๋ฅผ ๋ฐ”๊พธ์–ด ์ง„ํ–‰ํ•ด๋ณผ ๊ณ„ํš์ด๋‹ค.

๋ฐ”๋€Œ์–ด๋ฒ„๋ฆฐ redis ํฌํŠธ

์„œ๋ฒ„๋ฅผ 3001๋ฒˆ ํฌํŠธ๋กœ ์‹คํ–‰ํ•˜๋ ค๊ณ  deploy.sh์— ์„œ๋ฒ„ env ํŒŒ์ผ์˜ PORT:3000์„ PORT:3001๋กœ ๋ฐ”๊พธ๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ–ˆ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ, PORT:๋ฅผ ํŒŒ์‹ฑํ•˜๋Š” ๊ณผ์ •์—์„œ REDIS_PORT:๋„ ํŒŒ์‹ฑ๋˜์–ด ํฌํŠธ๊ฐ€ ๋ฐ”๋€Œ๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค ํ•˜ํ•˜;;

์ดํ›„ ๊ณผ์ •์—์„œ PORT๋ฅผ ๋ฐ”๊พธ์–ด์„œ ์‹คํ–‰ํ•˜์ง€ ์•Š์•„๋„ ๋˜์–ด์„œ ์ด ๋ถ€๋ถ„์ด ์ œ๊ฑฐ๋˜์—ˆ๊ณ , ๊ฒฐ๊ตญ ํ•ด๊ฒฐ๋˜์—ˆ๋‹ค.

ํฌํŠธ๋Š” ์˜๋ฏธ์—†๋‹ค..

ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„๋ฅผ ๊ทธ๋ฆฐ/๋ธ”๋ฃจ๋กœ ๋„์šฐ๋ ค๋ฉด, ์„œ๋กœ ๋‹ค๋ฅธ ํฌํŠธ๋กœ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค.
๊ทธ ์ด์œ ๋Š” ์ด๋ฏธ ํ•œ ์„œ๋ฒ„๊ฐ€ ์‹คํ–‰์ค‘์ธ ์ƒํƒœ์—์„œ ๋™์‹œ์— ๋‹ค๋ฅธ ์„œ๋ฒ„๋ฅผ ๋„์šฐ๊ณ ,
ํŠธ๋ž˜ํ”ฝ์„ ์˜ฎ๊ธฐ๊ณ , ํŠธ๋ž˜ํ”ฝ์ด ์˜ฎ๊ฒจ์กŒ์„ ๋•Œ, ๊ธฐ์กด ์„œ๋ฒ„๋ฅผ ์ข…๋ฃŒํ•˜๋Š” ๋ฐฉ์‹์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

์ง€๊ธˆ์˜ ๊ตฌ์กฐ์—์„œ๋Š” ์„œ๋ฒ„๊ฐ€ 3000ํฌํŠธ์ด๊ณ , ํด๋ผ์ด์–ธํŠธ๊ฐ€ 5173 ํฌํŠธ๋ฅผ ์“ด๋‹ค.
๊ทธ๋ž˜์„œ 1์”ฉ ๋”ํ•œ 3001, 5174๋ฅผ ์“ฐ๋ ค๊ณ  ํ–ˆ๋‹ค.

๋‹ค๋งŒ, ์—ฌ๊ธฐ์„œ์˜ ๋ฌธ์ œ๊ฐ€ server์—์„œ๋Š” .env์—์„œ PORT:3000, PORT:3001๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•ด์„œ
์‹คํ–‰ํ•˜๋ฉด ํ•ด๋‹น ํฌํŠธ๋กœ ์‹คํ–‰์ด ๋˜์ง€๋งŒ, ํด๋ผ์ด์–ธํŠธ๋Š” ์ด๋ฏธ์ง€์— ํฌํ•จ๋˜์–ด์žˆ๋Š” ์„ค์ • ํŒŒ์ผ๋“ค์„ ๊ฑด๋“œ๋ ค์•ผ ํ–ˆ๋‹คโ€ฆ.
๊ทธ๋ฆฌํ•˜์—ฌ ์„œ๋ฒ„์™€ ๊ฐ™์ด PORT ๋ฒˆํ˜ธ๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ , ๋„์ปค ์ปจํ…Œ์ด๋„ˆ์˜ ์™ธ๋ถ€ ํฌํŠธ, ๋‚ด๋ถ€ ํฌํŠธ๋ฅผ ๊ฑด๋“œ๋ ค ๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.

docker-compose ํŒŒ์ผ์˜ ์˜ต์…˜์œผ๋กœ expose์™€ ports๊ฐ€ ์žˆ์—ˆ๋‹ค.
expose๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ„ ์—ฐ๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ํฌํŠธ์ด๊ณ 
ports๋Š” ์‹ค์ œ ์™ธ๋ถ€์—์„œ ์ ‘๊ทผํ•  ํฌํŠธ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

์šฐ์„ ์€ nginx์™€๋งŒ ์†Œํ†ตํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ports๋Š” ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š๊ธฐ๋กœ ํ–ˆ๋‹ค.
๊ทธ๋ ‡๊ฒŒ expose์—์„œ 5174:5173์„ ์‹œ๋„ํ•ด๋ดค๋‹ค.
nginx์˜ client port ์„ค์ •์„ ๋ฐ”๊ฟ”์คฌ์Œ์—๋„ bad gateway๊ฐ€ ๋‚˜์™”๋‹ค.
์ด ๋ถ€๋ถ„์„ ports์— ์ ์šฉํ•ด๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์˜€๋‹ค.

์œ„ ์‹œ๋„์—์„œ์˜ ๋ฌธ์ œ์ ์€ expose๋Š” port:port ๊ตฌ์กฐ๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.
port:port ๊ตฌ์กฐ์—์„œ์˜ ์•ž port๋Š” ํ˜ธ์ŠคํŠธ(๋ฌผ๋ฆฌ ์ปดํ“จํ„ฐ)๊ฐ€ ์™ธ๋ถ€์— ์—ด์–ด๋‘๋Š” ํฌํŠธ์ด๊ณ 
๋’ค์˜ port๊ฐ€ ๋‚ด๋ถ€ 3000๋ฒˆ ํฌํŠธ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ๊ตฌ์กฐ์ด๋‹ค.

๊ฒฐ๊ณผ์ ์œผ๋กœ ์œ„ ๋ฐฉ์‹์€ ์˜ค๋žœ ์‹œ๊ฐ„ ๋์— ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๊ฒƒ์„ ์ธ์ง€ํ–ˆ๋‹คโ€ฆ
๋‹ค๋งŒ, ๊ณ„์†ํ•ด์„œ ํ•˜๋‹ค๋ณด๋‹ˆ ํ•œ ๊ฐ€์ง€ ๊นจ๋‹ฌ์€ ๊ฒƒ์ด ์žˆ์—ˆ๋‹ค.
๊ฐ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์„œ๋กœ ๋‹ค๋ฅธ ํฌํŠธ๊ฐ€ ์•„๋‹ˆ์–ด๋„ ๋œ๋‹ค๋Š” ์‚ฌ์‹ค์ด๋‹ค.
์ด ์‚ฌ์‹ค์„ ์•Œ๊ณ  ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์•ˆ๋„๊ฐ๊ณผ ์ด์ œ์„œ์•ผ ์•Œ์•˜๋‹ค๋Š” ์ž๊ดด๊ฐ์„ ๋Š๊ผˆ์ง€๋งŒ
์‹œ๊ฐ„์ด ์—†๊ธฐ์— ๋น ๋ฅด๊ฒŒ ์ ์šฉํ•ด๋ดค๋‹ค.
๊ฒฐ๊ณผ์ ์œผ๋กœ client-blue, client-green, server-blue, server-green 4๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๊ฐ๊ฐ
3000ํฌํŠธ์™€ 5173 ํฌํŠธ๋กœ ์—ด ์ˆ˜ ์žˆ์—ˆ๋‹คโ€ฆ ๐ŸŽ‰ ์ด๊ฒŒ ๊ฐ€๋Šฅํ•œ ์ด์œ ๋Š”, ๊ฐ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋กœ ๊ด€๋ฆฌ๋˜๊ธฐ ๋•Œ๋ฌธ์— ํฌํŠธ๊ฐ€ ์ถฉ๋Œ๋˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๊ทธ๋ ‡๊ฒŒ ์„œ๋ธŒ ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ธŒ ์„œ๋ฒ„ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋„์šฐ๊ณ  ์‹คํ–‰์ค‘์ด๋˜ ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ข…๋ฃŒํ•˜๊ฒŒ๋” ์ž‘์„ฑํ•˜์˜€๋‹ค.

๋’ค๋ฐ”๋€Œ์–ด ๋ฒ„๋ฆฐ client ๋ฐฐํฌ ๋ฐฉ์‹โ€ฆ

์œ„์—์„œ ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ์ ํŠธ ํŒŒ์ผ์„ 5173/5174๋กœ ํ•œ๋‹ค๊ณ  ํ–ˆ์—ˆ๋‹ค.
์ด๊ฑธ ์‹ค์ œ๋กœ ๊ตฌํ˜„ํ–ˆ์œผ๋‚˜ ํ•œ ๊ฐ€์ง€ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค.

ํŽ˜์ด์ง€๊ฐ€ ๋„ˆ๋ฌด ๋Š๋ฆฌ๊ฒŒ ๋กœ๋“œ๋œ๋‹ค.

์‚ฌ์šฉ์ž์—๊ฒŒ ์žˆ์–ด์„œ ํฐ ํ™”๋ฉด์„ 2์ดˆ ์ด์ƒ ๋…ธ์ถœํ•˜๋Š” ๊ฒƒ์ด ์ฉ ์ข‹์€ ๊ฒฝํ—˜์€ ์•„๋‹ˆ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.
๊ฒฐ๊ตญ ๋„์ปค ํ—ˆ๋ธŒ์—์„œ์˜ ๋ฒ„์ „๊ด€๋ฆฌ๋ฅผ ์œ ์ง€ํ•˜๋ฉด์„œ ์„œ๋ฒ„๋ฅผ ์œ ์ง€ํ•˜๊ฒ ๋‹ค๋Š” ๊ฟˆ์€ ๋ฌด๋„ˆ์กŒ๋‹ค.

๊ทธ๋ ‡๊ฒŒ ๋ฐฉ๋ฒ•์„ ์ฐพ๋‹ค๊ฐ€ ์„œ๋ฒ„์—์„œ 5173๋ฒˆ ํฌํŠธ๋กœ ํด๋ผ์ด์–ธํŠธ ํŒŒ์ผ์„ ์‹คํ–‰์‹œํ‚ค๋Š” ๊ฒƒ์ด ์ผ๋ฐ˜์ ์ธ ์„ ํƒ์€ ์•„๋‹ˆ๋ผ๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ๋˜์—ˆ๋‹ค. ๊ทธ๋ ‡๊ฒŒ client ์ด๋ฏธ์ง€๋ฅผ ์ง€์šฐ๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ์—ฌ๊ธฐ์„œ ๊ฐˆ๋ฆผ๊ธธ์ด ์ƒ๊ธด๋‹ค.

  1. scp๋กœ ๋„˜๊ฒจ์„œ ์‹คํ–‰์ค‘์ธ nginx๊ฐ€ ํ•ด๋‹น ํŒŒ์ผ์„ ๊ฐ€๋ฆฌํ‚ค๊ฒŒ ํ•œ๋‹ค.
  2. nginx ์ด๋ฏธ์ง€์— client ์ •์  ํŒŒ์ผ์„ ํฌํ•จ์‹œํ‚ค๊ณ , ์„œ๋ฒ„์ฒ˜๋Ÿผ blue/green ๊ธฐ๋ฒ• ์‚ฌ์šฉ

์ด์ „์˜ ์„ ํƒ์˜ ๊ฐˆ๋ฆผ๊ธธ์—์„œ๋„ scp๊ฐ€ ๋ฒ„์ „ ๊ด€๋ฆฌ๊ฐ€ ์•ˆ๋˜๊ธฐ ๋•Œ๋ฌธ์—
nginx ์ด๋ฏธ์ง€์— ํฌํ•จ์‹œํ‚ค๊ณ  ์ด ์ด๋ฏธ์ง€๋ฅผ ๋ฒ„์ „์œผ๋กœ ๊ด€๋ฆฌํ•˜๋ ค๊ณ  ํ–ˆ๋‹ค.

๊ทธ๋ ‡๊ฒŒ docker actions ์Šคํฌ๋ฆฝํŠธ์— client ํŒŒ์ผ์„ build ์‹œํ‚ค๊ณ  nginx Dockerfile์—์„œ COPY ํ–ˆ๋‹ค.

client๋ฅผ ๋นŒ๋“œ์‹œํ‚ฌ ๋•Œ yarn --cwd๋กœ ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ์‹คํ–‰๋˜๋„๋ก ํ–ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  yarn build๋ฅผ ์œ„ํ•ด์„œ yarn install์ด ์„ ํ–‰๋˜์–ด์•ผ ํ–ˆ๋‹ค.

๊ฒฐ๊ณผ์ ์œผ๋กœ ํŽ˜์ด์ง€๊ฐ€ ๋„์›Œ์กŒ๊ณ , ๋ธŒ๋ผ์šฐ์ €์—์„œ ํŽ˜์ด์ง€๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ ์ „๋ณด๋‹ค ๋น ๋ฅธ ์†๋„๋กœ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
์—ฌ๊ธฐ์„œ ๋์ธ์ค„ ์•Œ์•˜์œผ๋‚˜..

์ค‘์ฒฉ๋œ nginx port

nginx์— client ์ด๋ฏธ์ง€๋ฅผ ํฌํ•จํ•˜๊ณ  nginx-green, nginx-blue๋กœ ๊ด€๋ฆฌํ•˜๋ ค๊ณ  ํ–ˆ์œผ๋‚˜,
nginx์˜ 80ํฌํŠธ๋Š” ํ˜ธ์ŠคํŠธ์— ์˜ํ•ด ์™ธ๋ถ€์— ์ง์ ‘ ๋…ธ์ถœ๋˜๋Š” ํฌํŠธ๋กœ ์ค‘๋ณต์ด ๋ถˆ๊ฐ€๋Šฅ ํ–ˆ๋‹ค..
์ด์— ๋Œ€ํ•ด ๋” ๋ฐฉ๋ฒ•์„ ์ฐพ์•„๋ณผ์ง€, nginx์—์„œ client ํŒŒ์ผ์„ ๋ถ„๋ฆฌํ•  ์ง€๋ฅผ ๊ณ ๋ฏผํ–ˆ๋Š”๋ฐ,
nginx์™€ ๋…๋ฆฝ์ ์œผ๋กœ ๋Œ์•„๊ฐ€๋Š” ๊ฒƒ์ด ๋ฌธ์ œ ํ•ด๊ฒฐ๋„ ๊ฐ€๋Šฅํ•˜๊ณ , ๊ตฌ์กฐ์ƒ์œผ๋กœ ๋” ๋‚˜์„ ๊ฒƒ ๊ฐ™์•„์„œ ๋ถ„๋ฆฌํ•˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค.

nginx ์ด๋ฏธ์ง€๋Š” ๋”ฑํžˆ ์ฝ”๋“œ ํŒŒํŠธ์—์„œ ๋ฐ”๋€” ๋ถ€๋ถ„์ด ์—†๋‹ค๊ณ  ์ƒ๊ฐ๋˜์–ด github actions์—์„œ ์™„์ „ํžˆ ์ œ๊ฑฐํ•˜์˜€๋‹ค.

์„œ๋ฒ„์—์„œ docker-compose-nginx.yml๋กœ ๊ด€๋ฆฌ

buildํ•œ client dist ํŒŒ์ผ์— ๋Œ€ํ•ด์„œ๋Š” ์„œ๋ฒ„์˜ ํŠน์ • ๋””๋ ‰ํ† ๋ฆฌ๋กœ scp ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์ „์†กํ•˜์˜€๋‹ค.
์‹คํ–‰์ค‘์ธ nginx๊ฐ€ ์ „์†ก๋œ distํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ nginx์˜ default.conf ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด์ฃผ์–ด์•ผ ํ–ˆ๋‹ค.

  • nginx๊ฐ€ ๊ธฐ๋ณธ์œผ๋กœ ์ œ๊ณตํ•  ์›น ํŒŒ์ผ ๊ฒฝ๋กœ
  • ํŒŒ์ผ์ด ์•„๋‹Œ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์š”์ฒญ ํ–ˆ์„ ๋•Œ ๋””๋ ‰ํ† ๋ฆฌ์˜ ๊ธฐ๋ณธ ๋ฐ˜ํ™˜ ํŒŒ์ผ์„ ์ง€์ •
    • ์˜ˆ๋ฅผ ๋“ค์–ด /๊ฒฝ๋กœ๋„ ๋””๋ ‰ํ† ๋ฆฌ์ด๋‹ค. /์—๋Œ€ํ•œ ๊ธฐ๋ณธ ๋ฐ˜ํ™˜ ํŒŒ์ผ์„ index.html๋กœ ์ง€์ •ํ•˜๋ฉด ๊ฐ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์š”์ฒญ์ด ์™”์„ ๋•Œ, ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€์˜ index.html์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ตฌ์กฐ์ด๋‹ค.
    • ์ง€๊ธˆ์€ nginx์˜ distํŒŒ์ผ์ด root๊ธฐ ๋•Œ๋ฌธ์— /๋กœ ์š”์ฒญ์ด ์˜ค๋ฉด dist ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด์˜ index.html์ด ์‹คํ–‰๋œ๋‹ค.
  • try_files๋Š” ๋“ค์–ด์˜จ ์š”์ฒญ์— ๋Œ€ํ•ด $uri ํŒŒ์ผ์ด ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด $uri/๋กœ ๋‹ค์‹œ ์ฐพ์•„๋ณด๊ณ  ์ด๋งˆ์ € ์—†์œผ๋ฉด /index.html์„ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ํ•˜๋Š” ์„ค์ •์ด๋‹ค.

์œ„ ์„ธ๊ฐ€์ง€ ์„ค์ • ์ค‘ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์„ค์ •์€ root /usr/share/nginx/html/dist-green;์ด๋‹ค.
์ด๊ฒŒ ์‹ค์ œ dist๋ฅผ ๊ฐ€๋ฆฌ์ผœ์•ผ ์ž‘๋™ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

location / {
    root /usr/share/nginx/html/dist-green;
    index index.html index.htm;
    try_files $uri $uri/ /index.html;
}

์œ„ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ณด๋ฉด ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด dist-green์ด ๋ช…์‹œ๋˜์–ด์žˆ๋‹ค.
์ง์ „ ๋ฒ„์ „์„ ๋ฐฑ์—…ํ•˜๊ธฐ ์œ„ํ•ด distํŒŒ์ผ์„ ๋ฎ์–ด์”Œ์šฐ๋Š” ๊ฐœ๋…๋ณด๋‹ค dist-green dist-blue๋ฅผ ๋งŒ๋“ค๋„๋ก ํ–ˆ๋‹ค.

ํฐ ํ๋ฆ„์€ github actions์—์„œ nginx์˜ distํŒŒ์ผ๋กœ ์ „์†กํ•˜๊ณ , deploy.sh์—์„œ distํŒŒ์ผ์„ cpํ•˜์—ฌ ๊ฐ ์ปฌ๋Ÿฌ์— ๋งž๊ฒŒ dist-green์ด๋‚˜ dist-blue๋กœ ๋ฎ์–ด์”Œ์šฐ๊ฒŒ ํ–ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ํ–ˆ์„ ๋•Œ ํด๋ผ์ด์–ธํŠธ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ dist-blue๋ฅผ ์‹คํ–‰์ค‘์ด๋ผ๋ฉด dist-green์„ ์‹คํ–‰ํ•˜๊ณ  dist-blue๋ฅผ ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ๋‹ค.

์ดˆ๊ธฐ์—๋Š” dist-green์ด๋‚˜ dist-blue๋กœ cpํ•˜๊ณ  rmํ–ˆ์—ˆ๋Š”๋ฐ, ๊ทธ๋ ‡๊ฒŒ ํ•˜์ง€ ์•Š์€ ์ด์œ ๋Š”
deploy.sh์—์„œ ์‹คํ–‰๋  ๋•Œ dist ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ๋ฌด์กฐ๊ฑด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ณ  blue๋‚˜ green์œผ๋กœ ๋ณต์‚ฌํ•˜๋Š”๋ฐ,
GitHub Actions์˜ scp ์—†์ด ์„œ๋ฒ„์—์„œ green๊ณผ blue๋กœ ์ „ํ™˜ํ•  ๋•Œ ์œ„์™€๊ฐ™์€ ์ด์œ ๋กœ dist ํŒŒ์ผ์ด ํ•„์š”ํ•ด์„œ rmํ•˜์ง€ ์•Š๊ณ  ๋‘๊ฒŒ ๋˜์—ˆ๋‹ค.

์„œ๋ฒ„๋Š” ์™œ ๋˜ ๋ง์ฝ์ธ๊ฐ€

์œ„ ๊ณผ์ • ํ›„ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ ‘๊ทผํ–ˆ์„ ๋•Œ, ํŽ˜์ด์ง€๋Š” ์ž˜ ๋„์›Œ์กŒ๋‹ค.
๊ทธ๋Ÿฐ๋ฐโ€ฆ ์„œ๋ฒ„๊ฐ€ ์•ˆ ๋„์›Œ์ง€๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ๋ณด์˜€๋‹ค..
์ •ํ™•ํžˆ ์–˜๊ธฐํ•˜๋ฉด docker logs๋กœ ๋ณธ ์„œ๋ฒ„ ๋กœ๊ทธ๋Š” ์ •์ƒ์ ์œผ๋กœ nestjs๊ฐ€ ์‹คํ–‰๋˜์—ˆ๋‹ค๊ณ  ๋‚˜์˜ค์ง€๋งŒ,
api๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š์€ ๋ฌธ์ œ์˜€๋‹ค.

๋‚˜๋Š” ์ด ๋ฌธ์ œ๊ฐ€ ๋‹จ์ˆœํžˆ

  1. ์„œ๋ฒ„๊ฐ€ ๋Š๋ฆฌ๊ฒŒ ์ผœ์ง€๋Š” ๊ฑด๊ฐ€?
  2. ํฌํŠธ์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋‚˜?
  3. ๋„คํŠธ์›Œํฌ๊ฐ€ ๋‹ค๋ฅธ๊ฐ€?

๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

์šฐ์„ ์€ ๊ฐ™์€ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์ธ์ง€ ํ™•์ธํ–ˆ๋‹ค.

docker inspect webapp

image

์ด ๋‘˜์€ ๊ฐ™์€ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์— ์žˆ์—ˆ๋‹คโ€ฆ

๊ทธ๋Ÿผ ํฌํŠธ ๋ฌธ์ œ์ธ๊ฐ€?
์‚ฌ์‹ค ํฌํŠธ ๋ฌธ์ œ์ธ์ง€ ํ™•์ธํ•˜๊ธฐ ์ „์— ๊ฐ‘์ž๊ธฐ swagger์˜ /api ๊ฐ€ ์ ‘์†๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค. ํฌํŠธ์˜ ๋ฌธ์ œ๋Š” ์•„๋‹ˆ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

๋งˆ์ง€๋ง‰์œผ๋กœ ์„œ๋ฒ„๊ฐ€ ๋Š๋ฆฌ๊ฒŒ ์ผœ์ง€๋Š” ๊ฑด์ง€์— ๋Œ€ํ•œ ์˜๋ฌธ์„ ๊ฐ€์ง€๊ฒŒ ๋˜์—ˆ๋‹ค.
์„œ๋ฒ„๋Š” ๊ตฌํ˜„์„ ๋งŽ์ด ํ•ด๋†“์ง€ ์•Š์•„์„œ ๋Š๋ฆฌ๊ฒŒ ๋™์ž‘ํ•  ์ด์œ ๊ฐ€ ์—†์—ˆ๊ณ ,
์„œ๋ฒ„๊ฐ€ ์ผœ์กŒ๋‹ค๋Š” ๋กœ๊ทธ๋„ ์ •์ƒ์ ์œผ๋กœ ์ถœ๋ ฅ๋˜์—ˆ๋‹ค.
๊ทธ๋ž˜์„œ ์ผ๋‹จ ํŒŒ์ผ์„ ํ•˜๋‚˜์”ฉ ์—ด์—ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ค๊ฐ€ deploy.sh๋ฅผ ์—ด๊ฒŒ ๋˜์—ˆ๋‹ค.

health์ฒดํฌ ํ›„ ์ •์ƒ์ ์œผ๋กœ health ์ฒดํฌ๊ฐ€ ๋˜์—ˆ์„ ๋•Œ nginx ์„ค์ •์„ ์ˆ˜์ •ํ•˜๋„๋ก ํ–ˆ๋Š”๋ฐ,
health ์ฒดํฌ๊ฐ€ starting์œผ๋กœ ๋‚˜์˜ค๋˜ ๋ฌธ์ œ์˜€๋‹ค..
๊ทธ๋ž˜์„œ ํ•จ์ˆ˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ 5์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ health ์ฒดํฌ๋ฅผ ํ•˜๋„๋ก ํ•˜๊ณ , starting์ด ์•„๋‹Œ ์ƒํƒœ๊ฐ€ ๋‚˜์™”์„ ๋•Œ
์ด ํ•จ์ˆ˜ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

๊ฒฐ๊ณผ๋Š” ๋ธŒ๋ผ์šฐ์ € ํ™˜๊ฒฝ์—์„œ /api ๋ฅผ ํ™•์ธํ•ด๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
์ด์— ๋”ํ•ด docker compose ํŒŒ์ผ์—๋„ ์žฌ์‹œ๋„ ์ฟจํƒ€์ž„์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด ๊ธฐ์–ต๋‚˜์„œ
docker compose ํŒŒ์ผ์€ ์–ด๋–ป๊ฒŒ ์„ค์ •์ด ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด๊ฒŒ ๋˜์—ˆ๋‹ค.
docker compose ํŒŒ์ผ์€ 1m30s๋กœ ๋˜์–ด ์žˆ์—ˆ๋‹ค..
์ด ๋ถ€๋ถ„ ๋•Œ๋ฌธ์—๋„ ์„œ๋ฒ„๊ฐ€ ๋Šฆ๊ฒŒ ์‹œ์ž‘๋œ ๊ฒƒ์ด ์•„๋‹Œ๊ฐ€๋ผ๋Š” ์ƒ๊ฐ์ด๋“ ๋‹ค.

๊ฒฐ๊ณผ

server ์ปจํ…Œ์ด๋„ˆ๋Š” ์‹คํ–‰๋˜๊ณ  ์–ผ๋งˆ ์ง€๋‚˜์ง€ ์•Š์•„ healthyํ•œ ์ƒํƒœ๋กœ ๋ฐ”๋€Œ๊ฒŒ ๋˜์—ˆ๋‹ค.
๋˜ํ•œ blue/green ๋ณ€๊ฒฝ ๊ณผ์ •์—์„œ health ์ฒดํฌ ํ›„ ๊ธฐ์กด ์„œ๋ฒ„๋ฅผ ๋‹ซ๊ฒŒ๋” ์ž‘์„ฑํ–ˆ๋‹ค ๋ณด๋‹ˆ, request๋„ ๋Š์ž„์—†์ด ์ „๋‹ฌ๋˜์—ˆ๋‹ค.

ํ”„๋ก ํŠธ ๋˜ํ•œ ์„ค์ • ํŒŒ์ผ์„ ๋ฐ”๊พธ๊ณ  reloadํ•˜๋Š” ์ฆ‰์‹œ ์ ์šฉ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฌธ์ œ ์—†์ด ๋ฐฐํฌ๊ฐ€ ๋˜๊ณ  ์žˆ๋‹ค.

inear

๊ธฐ์ˆ  ๊ณต์œ 

๐Ÿš€ ffmpeg๋Š” stderr๋กœ ๋””๋ฒ„๊น…์„ ํ•˜๋Š” ์ด์œ 
๐Ÿš€ HLS ํ”„๋กœํ† ์ฝœ์— ๊ด€ํ•œ ์ •๋ฆฌ ๋ฐ FFmpeg ์‚ฌ์šฉ๊ธฐ
๐Ÿš€ ๋น„ํŠธ๋Š” tsconfig.json์ด ์„ธ ๊ฐœ?
๐Ÿš€ NestJS ๊ธฐ๋ณธ ๊ฐœ๋… - Modules
๐Ÿš€ Socket.io ์ตœ(๊ฐ•)์ ํ™”
๐Ÿš€ ๋„์ปค์™€ nginx์˜ ์‚ฌ์šฉ๊ธฐ
๐Ÿš€ ๋ถ€ํ•˜ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด์ž

๊ฐœ๋ฐœ ์ผ์ง€

๐Ÿš€ FSD ์‚ฌ์šฉ๊ธฐ, ๊ทผ๋ฐ ์ด์ œ ๋‚˜๋งŒ์˜ ๊ทœ์น™์„ ๊ณ๋“ค์ธ
๐Ÿš€ CICD ๊ตฌ์กฐ ์ˆ˜์ •
๐Ÿš€ ์•จ๋ฒ” ๋‹จ์œ„๋กœ ์ŠคํŠธ๋ฆฌ๋ฐ ํ•˜๊ธฐ (with HLS)
๐Ÿš€ HLS๋กœ ์Œ์•… ์ฃผ๊ณ ๋ฐ›๊ธฐ
๐Ÿš€ vite + react + typescript ํ™˜๊ฒฝ์—์„œ path alias ์„ค์ •
๐Ÿš€ React Scan์ด ๋ญ์ฃ ?
๐Ÿš€ ๋กœ์ปฌ ํ™˜๊ฒฝ ๊ฐœ๋ฐœ ๋ชจ๋“œ ๋ฐฐํฌ
๐Ÿš€ ์•จ๋ฒ” ์ „์ฒด๋ฅผ ์ŠคํŠธ๋ฆฌ๋ฐํ•œ๋‹ค๊ณ ? (with HLS)
๐Ÿš€ ์ฝ”๋“œ์˜ ์•ˆ์ •์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ํ…Œ์ŠคํŠธ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด์ž

ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

๐Ÿš€ ์ƒˆ๋กœ๊ณ ์นจ ์‹œ HLS ERROR
๐Ÿš€ input ํƒœ๊ทธ์— ํ•œ๊ธ€ ์ž…๋ ฅ ํ›„, Enter๋ฅผ ๋ˆ„๋ฅด๋ฉด ํ•จ์ˆ˜๊ฐ€ ๋‘๋ฒˆ ํ˜ธ์ถœ๋˜๋Š” ์˜ค๋ฅ˜
๐Ÿš€ nginx proxy pass๋ฅผ ๋ฐ”๊ฟจ๋”๋‹ˆ ์ƒ๊ธด ์—๋Ÿฌ - ์Šค์›จ๊ฑฐ ์ธ์‹ ๋ฌธ์ œ
๐Ÿš€ ๋ฐฐํฌ ํ™˜๊ฒฝ์—์„œ ํด๋ผ์ด์–ธํŠธ-์„œ๋ฒ„ WS handshake
๐Ÿš€ ๋ Œ๋”๋ง ๋ฒ”์ธ์€ ํ•˜๋‚˜!

ํ˜‘์—… ๊ทœ์น™

๐ŸŒˆ ๊ทธ๋ผ์šด๋“œ ๋ฃฐ
๐Ÿฅ” ํŒ€์› ์†Œ๊ฐœ
๐Ÿ”Ž ์ฝ”๋“œ & ๊นƒ ์ปจ๋ฒค์…˜
๐ŸŒณ ๊นƒ branch ์ „๋žต
๐Ÿ“Œ ๋…ธ์…˜ ๋ฌธ์„œ ์ €์žฅ์†Œ

ํ”„๋กœ์ ํŠธ ๊ธฐํš

๐ŸŽจ ํ”ผ๊ทธ๋งˆ
๐Ÿง‘โ€๐Ÿ’ป ๊ธฐํš ๊ณต์œ  ๋ฐœํ‘œ ์ž๋ฃŒ
๐ŸŽค 2์ฃผ์ฐจ ๋ฐœํ‘œ ์ž๋ฃŒ
๐Ÿ˜Ž ๋ฐฑ๋กœ๊ทธ

๋ฐ์ผ๋ฆฌ ์Šคํฌ๋Ÿผ

๐Ÿ“ 1์ฃผ์ฐจ
๐Ÿ“ 2์ฃผ์ฐจ
๐Ÿ“ 3์ฃผ์ฐจ
๐Ÿ“ 4์ฃผ์ฐจ
๐Ÿ“ 5์ฃผ์ฐจ

์ฃผ๊ฐ„ ๊ณ„ํš์„œ

๐Ÿ—“๏ธ 1์ฃผ์ฐจ
๐Ÿ—“๏ธ 2์ฃผ์ฐจ
๐Ÿ—“๏ธ 3์ฃผ์ฐจ
๐Ÿ—“๏ธ 4์ฃผ์ฐจ
๐Ÿ—“๏ธ 5์ฃผ์ฐจ

๊ทธ๋ฃน ํšŒ๊ณ 

โœจ 1์ฃผ์ฐจ
โœจ 2์ฃผ์ฐจ
โœจ 3์ฃผ์ฐจ
โœจ 4์ฃผ์ฐจ


view

Clone this wiki locally