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