Files
banben/docker-compose.yml
T
2026-10-16 16:28:39 +08:00

69 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# =====================================================================
# 版本资源联合服务系统 - Docker Compose 编排
#
# 说明:
# - 为便于本地/开发验证,数据库默认使用官方 postgres 镜像。
# - 生产国产化环境请将 db 服务替换为瀚高(HighGo)镜像,
# 并将后端 profile 与驱动切换为瀚高(见 backend/application-prod.yml)。
# - 离线环境:先在可联网机器 docker save 镜像,再在有网隔离机器 docker load。
# =====================================================================
services:
# ---------------- 数据库 ----------------
db:
image: postgres:16-alpine # 生产替换:瀚高 HighGo 镜像
container_name: banben-db
restart: unless-stopped
environment:
POSTGRES_DB: ${DB_NAME:-banben}
POSTGRES_USER: ${DB_USER:-banben}
POSTGRES_PASSWORD: ${DB_PASSWORD:-banben123}
TZ: Asia/Shanghai
volumes:
- db-data:/var/lib/postgresql/data
- ./deploy/db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "${DB_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-banben} -d ${DB_NAME:-banben}"]
interval: 10s
timeout: 5s
retries: 5
# ---------------- 后端 ----------------
backend:
build:
context: ./backend
image: banben-backend:1.0.0
container_name: banben-backend
restart: unless-stopped
environment:
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-prod}
DB_HOST: db
DB_PORT: 5432
DB_NAME: ${DB_NAME:-banben}
DB_USER: ${DB_USER:-banben}
DB_PASSWORD: ${DB_PASSWORD:-banben123}
TZ: Asia/Shanghai
depends_on:
db:
condition: service_healthy
ports:
- "${BACKEND_PORT:-8080}:8080"
volumes:
- ./logs/backend:/app/logs
# ---------------- 前端(Nginx)----------------
frontend:
build:
context: ./frontend
image: banben-frontend:1.0.0
container_name: banben-frontend
restart: unless-stopped
depends_on:
- backend
ports:
- "${FRONTEND_PORT:-80}:80"
volumes:
db-data: