From 4b339d9d4f9df8ca2befa9a76edeebbe516513e8 Mon Sep 17 00:00:00 2001 From: gahusb Date: Sat, 4 Apr 2026 14:03:58 +0900 Subject: [PATCH] =?UTF-8?q?deployer:=20Docker=20CLI=20=EC=84=A4=EC=B9=98?= =?UTF-8?q?=20=EB=B0=A9=EC=8B=9D=20=EA=B0=9C=EC=84=A0=20+=20=ED=97=AC?= =?UTF-8?q?=EC=8A=A4=EC=B2=B4=ED=81=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: docker.io → docker-ce-cli + docker-compose-plugin (Docker 공식 저장소) - python:3.12-slim에서 docker.io가 제대로 동작하지 않던 문제 해결 - root 유저로 실행하여 Docker 소켓 접근 보장 - deploy.sh: 헬스체크 URL을 서비스명:내부포트로 변경 - 컨테이너 내부에서 localhost:18000 접근 불가 문제 해결 Co-Authored-By: Claude Opus 4.6 --- deployer/Dockerfile | 18 ++++++++++-------- scripts/deploy.sh | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/deployer/Dockerfile b/deployer/Dockerfile index a7ffd25..6039ef0 100644 --- a/deployer/Dockerfile +++ b/deployer/Dockerfile @@ -1,22 +1,24 @@ FROM python:3.12-slim +# Docker CE CLI + Compose Plugin (공식 저장소에서 설치) RUN apt-get update && apt-get install -y --no-install-recommends \ - git rsync ca-certificates curl util-linux \ - docker.io \ + git rsync ca-certificates curl util-linux gnupg \ + && install -m 0755 -d /etc/apt/keyrings \ + && curl -fsSL https://download.docker.com/linux/debian/gpg \ + | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \ + https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" \ + > /etc/apt/sources.list.d/docker.list \ + && apt-get update \ + && apt-get install -y --no-install-recommends docker-ce-cli docker-compose-plugin \ && rm -rf /var/lib/apt/lists/* -RUN groupadd -g 100 nasusers 2>/dev/null || true \ - && groupadd -g 65540 dockerhost \ - && useradd -u 1026 -g 100 -G 65540 -m deployer - WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY app.py /app/app.py -USER deployer - ENV PYTHONUNBUFFERED=1 EXPOSE 9000 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "9000"] diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 456f6a5..90c0620 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -50,7 +50,7 @@ ls -dt "$DST/.releases"/*/ 2>/dev/null | tail -n +6 | xargs -r rm -rf # ── 소스 → 운영 반영 ── bash "$SRC/scripts/deploy-nas.sh" -# ── 컨테이너 재빌드 (deployer 제외 — 자기 자신을 재빌드하면 스크립트 중단됨) ── +# ── 변경된 서비스만 재빌드 (deployer 제외 — 자기 자신을 재빌드하면 스크립트 중단됨) ── cd "$DST" docker compose up -d --build backend travel-proxy stock-lab music-lab frontend docker exec lotto-frontend nginx -s reload 2>/dev/null || true @@ -60,7 +60,8 @@ echo "Waiting for services to start..." sleep 5 HEALTH_OK=true -for endpoint in "http://localhost:18000/health" "http://localhost:18500/health" "http://localhost:19000/health" "http://localhost:18600/health"; do +# 컨테이너 내부에서는 서비스명 + 내부포트(8000)로 접근 +for endpoint in "http://backend:8000/health" "http://stock-lab:8000/health" "http://travel-proxy:8000/health" "http://music-lab:8000/health"; do if ! curl -sf --max-time 10 --retry 2 --retry-delay 3 "$endpoint" > /dev/null 2>&1; then echo "HEALTH_FAIL: $endpoint" HEALTH_OK=false