Documents

Docker GitOps: Automating Container Deployments

4 min readJun 1, 2025Jun 1, 2025

temp_project - GitOps Experiment

temp_project is an experiment in Docker-based GitOps deployment automation. In June 2025, the basic structure was established in a single commit.

GitOps Pattern

flowchart TD
    A[Git Push] --> B[GitHub Actions]
    B --> C[Docker Build]
    C --> D[이미지 Push]
    D --> E[환경 별 배포]

    E --> F[Dev 서버]
    E --> G[Staging 서버]
    E --> H[Prod 서버]

    I[Git Repository] -->|Single Source of Truth| B

Core Principles of GitOps

  1. Declarative configuration: infrastructure defined as code
  2. Version control: every change recorded in Git
  3. Automatic synchronization: Git ↔ live infrastructure kept in sync automatically
  4. Self-healing: drift is automatically corrected

Actual Deployment Flow

# docker-compose.yml
version: '3.8'
services:
  app:
    image: ${REGISTRY}/${IMAGE}:${TAG}
    restart: always
    environment:
      - NODE_ENV=production
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 30s
      timeout: 10s
      retries: 3

Zero-Downtime Deployment

# 롤링 업데이트
docker compose pull
docker compose up -d --no-deps --build app

# 헬스체크 대기
until curl -sf http://localhost:3000/health; do sleep 2; done
echo "배포 완료"

It was only a single-commit experiment, but this pattern became the foundation for the hr_blog2.0 and XGen deployments. Tracking every infrastructure change through Git is a habit worth building.

Tags
GitOpsDockerDeployment AutomationCI/CDZero-Downtime Deployment