feat: add docker compose full deploy
This commit is contained in:
parent
a186439b84
commit
c38a4f0f62
|
|
@ -0,0 +1,12 @@
|
||||||
|
# MySQL/MariaDB Settings
|
||||||
|
MYSQL_ROOT_PASSWORD=your_strong_root_password
|
||||||
|
MYSQL_DATABASE=maildb
|
||||||
|
MYSQL_USER=root
|
||||||
|
MYSQL_PASSWORD=root_password
|
||||||
|
|
||||||
|
# Backend Database Settings
|
||||||
|
# These should match the MySQL/MariaDB settings above
|
||||||
|
DB_HOST=mysql
|
||||||
|
DB_USER=${MYSQL_USER}
|
||||||
|
DB_PASSWORD=${MYSQL_PASSWORD}
|
||||||
|
DB_NAME=${MYSQL_DATABASE}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
version: '3.3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# 1. 后端服务 (Node.js + Express + SMTP Server)
|
||||||
|
backend:
|
||||||
|
build: ./backend
|
||||||
|
container_name: email-backend
|
||||||
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- compose.full.env
|
||||||
|
networks:
|
||||||
|
- email-network
|
||||||
|
# 不直接暴露端口给外部,由 Nginx 统一代理
|
||||||
|
# ports:
|
||||||
|
# - "5182:5182"
|
||||||
|
# - "25:25"
|
||||||
|
|
||||||
|
# 2. 数据库服务 (MySQL)
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.0
|
||||||
|
container_name: email-mysql
|
||||||
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- compose.full.env
|
||||||
|
volumes:
|
||||||
|
- mysql-data:/var/lib/mysql
|
||||||
|
networks:
|
||||||
|
- email-network
|
||||||
|
|
||||||
|
# 3. Nginx 反向代理
|
||||||
|
nginx:
|
||||||
|
image: nginx:latest
|
||||||
|
container_name: email-nginx
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "7614:80" # HTTP
|
||||||
|
- "443:443" # HTTPS (需要SSL证书)
|
||||||
|
- "25:25" # SMTP 端口,转发给后端
|
||||||
|
volumes:
|
||||||
|
# 挂载前端构建好的静态文件
|
||||||
|
- ./frontend/dist:/usr/share/nginx/html
|
||||||
|
# 挂载 Nginx 配置文件
|
||||||
|
- ./nginx.full.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
# (可选) 挂载 SSL 证书
|
||||||
|
# - ./certs:/etc/nginx/certs:ro
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
- mysql
|
||||||
|
networks:
|
||||||
|
- email-network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
email-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql-data: {}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
events {}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 7614;
|
||||||
|
|
||||||
|
# 前端静态文件
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 后端 API 转发
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://backend:5182;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stream {
|
||||||
|
server {
|
||||||
|
listen 25;
|
||||||
|
proxy_pass backend:25;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue