Files
frontend_v2/docker-compose.yml
toom1996 5a8dbf41cb
Some checks failed
deploy / deploy (push) Has been cancelled
update
2026-08-11 22:29:47 +08:00

61 lines
1.6 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.

# 生产部署 compose放在前端仓库根服务器结构见 DEPLOY.md
# 前端仓: /opt/fashion/test (本文件所在)
# 后端仓: /opt/fashion/admin/backend
services:
# ---- 数据库 ----
db:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
MYSQL_DATABASE: ${DB_NAME:-fashionadmin}
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p${DB_PASSWORD:-root}"]
interval: 10s
timeout: 5s
retries: 10
# ---- 后端 (Go) ----
backend:
build:
context: ../admin/backend
restart: unless-stopped
environment:
SERVER_PORT: 8090
GIN_MODE: release
JWT_SECRET: ${JWT_SECRET:-change-me-in-prod}
DB_HOST: db
DB_PORT: 3306
DB_USER: ${DB_USER:-root}
DB_PASSWORD: ${DB_PASSWORD:-root}
DB_NAME: ${DB_NAME:-fashionadmin}
ports:
- "8090:8090" # 仅构建期前端拉数据用;生产可去掉,改由前端 nginx 反代
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8090/api/public/brands?size=1"]
interval: 10s
timeout: 5s
retries: 10
# ---- 前端 (Astro 静态 + nginx) ----
frontend:
build:
context: .
args:
API_SSR: http://localhost:8090 # 构建期 SSR 拉数据:配合 network: host 访问已起的 backend
network: host
restart: unless-stopped
ports:
- "80:80"
depends_on:
backend:
condition: service_healthy
volumes:
db_data: