# epay-go/docker-compose.yml version: '3.8' services: # PostgreSQL 数据库 postgres: image: postgres:16-alpine container_name: epay-postgres restart: unless-stopped env_file: - .env environment: POSTGRES_USER: ${DB_USER:-epay} POSTGRES_PASSWORD: ${DB_PASSWORD:-epay123} POSTGRES_DB: ${DB_NAME:-epay} volumes: - postgres_data:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-epay}"] interval: 10s timeout: 5s retries: 5 # Redis 缓存 redis: image: redis:7-alpine container_name: epay-redis restart: unless-stopped command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-} volumes: - redis_data:/data ports: - "6379:6379" healthcheck: test: ["CMD-SHELL", "redis-cli ${REDIS_PASSWORD:+-a $REDIS_PASSWORD} ping | grep PONG"] interval: 10s timeout: 5s retries: 5 # Go 后端 backend: build: context: . dockerfile: Dockerfile args: GOPROXY: ${GOPROXY:-https://goproxy.cn,direct} container_name: epay-backend restart: unless-stopped env_file: - .env environment: - DB_HOST=postgres - DB_PORT=5432 - DB_USER=${DB_USER:-epay} - DB_PASSWORD=${DB_PASSWORD:-epay123} - DB_NAME=${DB_NAME:-epay} - DB_SSLMODE=disable - REDIS_HOST=redis - REDIS_PORT=6379 - REDIS_PASSWORD=${REDIS_PASSWORD:-} - JWT_SECRET=${JWT_SECRET:-your-secret-key} - GIN_MODE=release ports: - "8080:8080" depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8080/health >/dev/null 2>&1 || exit 1"] interval: 15s timeout: 5s retries: 5 start_period: 10s # Vue 前端 frontend: build: context: ./web dockerfile: Dockerfile container_name: epay-frontend restart: unless-stopped ports: - "80:80" depends_on: backend: condition: service_healthy volumes: postgres_data: redis_data: