chore(deploy): 更新本地开发 docker-compose 使用 Java 后端

- docker-compose.yml: 替换 NestJS 后端为 Java (Spring Boot) + MySQL 8.0
  - 前端端口 3000:80,后端端口 8080:8080,MySQL 端口 3306:3306
- nginx.conf: proxy_pass 改为 http://backend:8080(Java 内部端口)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
lesingle 2026-03-03 15:41:28 +08:00
parent bbddb57104
commit 146923bcdd
2 changed files with 35 additions and 14 deletions

View File

@ -1,28 +1,49 @@
version: '3.8'
services:
mysql:
image: mysql:8.0
container_name: kg-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: reading_platform_pwd
MYSQL_DATABASE: reading_platform
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
backend:
build:
context: ./reading-platform-backend
container_name: kindergarten-backend
context: ./reading-platform-java
container_name: kg-backend
restart: unless-stopped
ports:
- "3001:3001"
- "8080:8080"
environment:
- PORT=3001
- NODE_ENV=production
- DATABASE_URL=file:/app/prisma/dev.db
- JWT_SECRET=${JWT_SECRET:-change-this-secret}
- JWT_EXPIRES_IN=7d
- FRONTEND_URL=http://localhost:8080
- PRISMA_QUERY_ENGINE_LIBRARY=/app/node_modules/.prisma/client/libquery_engine-linux-musl-openssl-3.0.x.so.node
- SPRING_PROFILES_ACTIVE=prod
- JWT_SECRET=${JWT_SECRET:-reading-platform-jwt-secret-key-must-be-at-least-256-bits-long}
volumes:
- uploads_data:/app/uploads
depends_on:
mysql:
condition: service_healthy
frontend:
build:
context: ./reading-platform-frontend
container_name: kindergarten-frontend
container_name: kg-frontend
restart: unless-stopped
ports:
- "8080:80"
- "3000:80"
depends_on:
- backend
volumes:
mysql_data:
uploads_data:

View File

@ -10,12 +10,12 @@ server {
# 反向代理后端 API
location /api/ {
proxy_pass http://backend:3001;
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /uploads/ {
proxy_pass http://backend:3001;
proxy_pass http://backend:8080;
}
}