version: '3.8' services: app: build: context: . dockerfile: Dockerfile args: BUILD_TIME: ${BUILD_TIME:-$(date -u +"%Y-%m-%dT%H:%M:%SZ")} GIT_COMMIT: ${GIT_COMMIT:-unknown} ports: - "8080:8080" environment: - GIN_MODE=release - PORT=8080 volumes: - ./.env:/root/.env restart: unless-stopped healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s # 可选:添加数据库服务 # postgres: # image: postgres:15-alpine # environment: # POSTGRES_DB: golang_demo # POSTGRES_USER: postgres # POSTGRES_PASSWORD: password # ports: # - "5432:5432" # volumes: # - postgres_data:/var/lib/postgresql/data # restart: unless-stopped # 可选:添加Redis服务 # redis: # image: redis:7-alpine # ports: # - "6379:6379" # restart: unless-stopped # volumes: # postgres_data: