docs: update deployment configurations for multi-module architecture
This commit is contained in:
+36
-13
@@ -19,28 +19,45 @@ services:
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
backend:
|
||||
gateway:
|
||||
build:
|
||||
context: ./novalon-manage-api
|
||||
context: ./novalon-manage-api/manage-gateway
|
||||
dockerfile: Dockerfile
|
||||
container_name: backend
|
||||
container_name: gateway
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
SPRING_R2DBC_URL: r2dbc:pool:postgresql://postgres:5432/manage_system
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/manage_system
|
||||
SPRING_DATASOURCE_USERNAME: postgres
|
||||
SPRING_DATASOURCE_PASSWORD: postgres
|
||||
SPRING_FLYWAY_URL: jdbc:postgresql://postgres:5432/manage_system
|
||||
SPRING_FLYWAY_USER: postgres
|
||||
SPRING_FLYWAY_PASSWORD: postgres
|
||||
SPRING_PROFILES_ACTIVE: prod
|
||||
JWT_SECRET: novalon-manage-secret-key-change-in-production
|
||||
JWT_EXPIRATION: 86400000
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
app:
|
||||
build:
|
||||
context: ./novalon-manage-api/manage-app
|
||||
dockerfile: Dockerfile
|
||||
container_name: app
|
||||
ports:
|
||||
- "8084:8084"
|
||||
environment:
|
||||
SPRING_PROFILES_ACTIVE: prod
|
||||
DB_HOST: postgres
|
||||
DB_PORT: 5432
|
||||
DB_NAME: manage_system
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: postgres
|
||||
JWT_SECRET: novalon-manage-secret-key-change-in-production
|
||||
JWT_EXPIRATION: 86400000
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- backend_uploads:/app/uploads
|
||||
- app_uploads:/app/uploads
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
frontend:
|
||||
build:
|
||||
@@ -50,8 +67,14 @@ services:
|
||||
ports:
|
||||
- "3000:80"
|
||||
depends_on:
|
||||
- backend
|
||||
- gateway
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
networks:
|
||||
novalon-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
backend_uploads:
|
||||
app_uploads:
|
||||
|
||||
@@ -64,10 +64,12 @@ mvn flyway:migrate
|
||||
|
||||
```bash
|
||||
# 创建 .env 文件
|
||||
cat > novalon-manage-api/manage-sys/.env << EOF
|
||||
SPRING_DATASOURCE_URL=r2dbc:pool:postgresql://localhost:55432/manage_system
|
||||
SPRING_DATASOURCE_USERNAME=postgres
|
||||
SPRING_DATASOURCE_PASSWORD=postgres
|
||||
cat > novalon-manage-api/manage-app/.env << EOF
|
||||
DB_HOST=localhost
|
||||
DB_PORT=55432
|
||||
DB_NAME=manage_system
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=postgres
|
||||
JWT_SECRET=novalon-manage-secret-key-change-in-production
|
||||
JWT_EXPIRATION=86400000
|
||||
EOF
|
||||
@@ -76,24 +78,24 @@ EOF
|
||||
#### 启动后端服务
|
||||
|
||||
```bash
|
||||
cd novalon-manage-api/manage-sys
|
||||
cd novalon-manage-api/manage-app
|
||||
|
||||
# 开发模式启动
|
||||
mvn spring-boot:run
|
||||
|
||||
# 或打包后启动
|
||||
mvn clean package
|
||||
java -jar target/manage-sys-1.0.0.jar
|
||||
java -jar target/manage-app-1.0.0.jar
|
||||
```
|
||||
|
||||
#### 验证后端服务
|
||||
|
||||
```bash
|
||||
# 健康检查
|
||||
curl http://localhost:8080/actuator/health
|
||||
curl http://localhost:8084/actuator/health
|
||||
|
||||
# 查看 API 文档
|
||||
open http://localhost:8080/swagger-ui.html
|
||||
open http://localhost:8084/swagger-ui.html
|
||||
```
|
||||
|
||||
### 2.3 前端部署
|
||||
@@ -138,13 +140,25 @@ open http://localhost:5173
|
||||
|
||||
### 3.1 构建镜像
|
||||
|
||||
#### 后端镜像
|
||||
#### 网关镜像
|
||||
|
||||
```bash
|
||||
cd novalon-manage-api/manage-sys
|
||||
cd novalon-manage-api/manage-gateway
|
||||
|
||||
# 构建镜像
|
||||
docker build -t novalon-manage-api:latest .
|
||||
docker build -t novalon-manage-gateway:latest .
|
||||
|
||||
# 查看镜像
|
||||
docker images | grep novalon
|
||||
```
|
||||
|
||||
#### 应用镜像
|
||||
|
||||
```bash
|
||||
cd novalon-manage-api/manage-app
|
||||
|
||||
# 构建镜像
|
||||
docker build -t novalon-manage-app:latest .
|
||||
|
||||
# 查看镜像
|
||||
docker images | grep novalon
|
||||
@@ -186,25 +200,50 @@ services:
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
backend:
|
||||
image: novalon-manage-api:latest
|
||||
container_name: novalon-api
|
||||
gateway:
|
||||
image: novalon-manage-gateway:latest
|
||||
container_name: novalon-gateway
|
||||
environment:
|
||||
SPRING_DATASOURCE_URL: r2dbc:pool:postgresql://postgres:5432/manage_system
|
||||
SPRING_DATASOURCE_USERNAME: postgres
|
||||
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD:-postgres}
|
||||
SPRING_PROFILES_ACTIVE: prod
|
||||
JWT_SECRET: ${JWT_SECRET:-novalon-manage-secret-key}
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
- app
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:8080/actuator/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
app:
|
||||
image: novalon-manage-app:latest
|
||||
container_name: novalon-app
|
||||
environment:
|
||||
SPRING_PROFILES_ACTIVE: prod
|
||||
DB_HOST: postgres
|
||||
DB_PORT: 5432
|
||||
DB_NAME: manage_system
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: ${DB_PASSWORD:-postgres}
|
||||
JWT_SECRET: ${JWT_SECRET:-novalon-manage-secret-key}
|
||||
ports:
|
||||
- "8084:8084"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:8084/actuator/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
frontend:
|
||||
image: novalon-manage-web:latest
|
||||
@@ -212,9 +251,9 @@ services:
|
||||
ports:
|
||||
- "80:80"
|
||||
depends_on:
|
||||
- backend
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- gateway
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
@@ -226,6 +265,8 @@ services:
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
@@ -236,6 +277,12 @@ services:
|
||||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-admin}
|
||||
volumes:
|
||||
- grafana-data:/var/lib/grafana
|
||||
networks:
|
||||
- novalon-network
|
||||
|
||||
networks:
|
||||
novalon-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
@@ -3,7 +3,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: manage-app
|
||||
uri: http://manage-app:8081
|
||||
uri: http://app:8084
|
||||
predicates:
|
||||
- Path=/api/**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user