129 lines
3.0 KiB
YAML
129 lines
3.0 KiB
YAML
services:
|
|
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
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-epay}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: epay-redis
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-}
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "redis-cli ${REDIS_PASSWORD:+-a $REDIS_PASSWORD} ping | grep PONG"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
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
|
|
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
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
frontend:
|
|
build:
|
|
context: ./web
|
|
dockerfile: Dockerfile
|
|
container_name: epay-frontend
|
|
restart: unless-stopped
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
caddy:
|
|
image: caddy:2.8-alpine
|
|
container_name: epay-caddy
|
|
restart: unless-stopped
|
|
depends_on:
|
|
frontend:
|
|
condition: service_started
|
|
backend:
|
|
condition: service_healthy
|
|
environment:
|
|
- SITE_ADDRESS=${SITE_ADDRESS:-localhost}
|
|
- ACME_EMAIL=${ACME_EMAIL:-}
|
|
volumes:
|
|
- ./deploy/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
|
|
- caddy_data:/data
|
|
- caddy_config:/config
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
volumes:
|
|
caddy_data:
|
|
caddy_config:
|
|
postgres_data:
|
|
redis_data:
|