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' version: '3.8'
services: 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: backend:
build: build:
context: ./reading-platform-backend context: ./reading-platform-java
container_name: kindergarten-backend container_name: kg-backend
restart: unless-stopped restart: unless-stopped
ports: ports:
- "3001:3001" - "8080:8080"
environment: environment:
- PORT=3001 - SPRING_PROFILES_ACTIVE=prod
- NODE_ENV=production - JWT_SECRET=${JWT_SECRET:-reading-platform-jwt-secret-key-must-be-at-least-256-bits-long}
- DATABASE_URL=file:/app/prisma/dev.db volumes:
- JWT_SECRET=${JWT_SECRET:-change-this-secret} - uploads_data:/app/uploads
- JWT_EXPIRES_IN=7d depends_on:
- FRONTEND_URL=http://localhost:8080 mysql:
- PRISMA_QUERY_ENGINE_LIBRARY=/app/node_modules/.prisma/client/libquery_engine-linux-musl-openssl-3.0.x.so.node condition: service_healthy
frontend: frontend:
build: build:
context: ./reading-platform-frontend context: ./reading-platform-frontend
container_name: kindergarten-frontend container_name: kg-frontend
restart: unless-stopped restart: unless-stopped
ports: ports:
- "8080:80" - "3000:80"
depends_on: depends_on:
- backend - backend
volumes:
mysql_data:
uploads_data:

View File

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