mengstack-website/guide/docker-deploy.md
2026-10-02 23:55:36 +08:00

73 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Docker 部署
MengStack 提供开箱即用的 Docker Compose 配置,一键启动完整开发/生产环境。
## 快速启动
```bash
# 启动所有服务(后台运行)
docker-compose up -d
# 查看服务状态
docker-compose ps
# 查看日志
docker-compose logs -f app
```
## 服务组成
```yaml
services:
app: # MengStack 应用(端口 2222)
postgres: # PostgreSQL 数据库(端口 5432)
redis: # Redis 缓存(端口 6379)
```
## 常用命令
```bash
# 启动
docker-compose up -d
# 停止
docker-compose down
# 重新构建并启动
docker-compose up -d --build
# 查看应用日志
docker-compose logs -f app
# 进入应用容器
docker-compose exec app sh
# 进入数据库
docker-compose exec postgres psql -U postgres -d mengstack
```
## 数据持久化
PostgreSQL 和 Redis 数据通过 Docker Volume 持久化:
```yaml
volumes:
postgres_data:
redis_data:
```
清除数据重新开始:
```bash
docker-compose down -v
docker-compose up -d
```
## 生产部署建议
1. **修改默认密码**:`docker-compose.yml` 中的数据库密码
2. **设置 release 模式**:`MENGSTACK_SERVER_MODE=release`
3. **配置 HTTPS**:在反向代理(Nginx/Caddy)层处理
4. **限制端口暴露**:数据库和 Redis 不对外暴露
5. **定期备份**:PostgreSQL 数据定时备份