Files
auto-solution/docker/README.md
2026-04-09 15:13:10 +08:00

53 lines
1.9 KiB
Markdown
Raw 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 部署说明
## 前置条件
- 安装 [Docker Desktop](https://www.docker.com/products/docker-desktop/)Windows 需开启 WSL2
- 项目根目录:`auto-solution`(与 `Dockerfile``docker-compose.yml` 同级)。
## 快速开始
1. **准备数据库脚本**(首次必做)
将 SQL 放到 `docker/mysql/init/`,详见 [mysql/init/README.md](mysql/init/README.md)。
2. **环境变量(可选)**
```bash
copy .env.example .env
```
按需修改 `MYSQL_ROOT_PASSWORD`、`REDIS_PASSWORD` 等;若 Redis 设密码,需在 `.env` 中填写 `REDIS_PASSWORD`,并与应用一致。
3. **构建并启动**
```bash
docker compose build
docker compose up -d
```
4. **访问**
- 后端:<http://localhost:1777>(默认映射,可在 `.env` 改 `APP_PORT`
- MySQL宿主机端口默认 `3307`(避免与本机 3306 冲突)
- Redis宿主机端口默认 `6379`(与容器内端口一致,可通过 `.env` 中 `REDIS_PORT` 修改)
## 仅构建应用镜像
```bash
docker build -t auto-solution-admin:latest .
```
## 配置说明
- 容器内使用 Spring 配置:`druid` + `docker`,见 `auto-solution-admin/src/main/resources/application-docker.yml`。
- 数据源与 Redis 主机名在 Compose 中为 `mysql`、`redis`,勿改服务名除非同步改配置。
## 上传文件
附件目录使用数据卷 `app_upload`,持久化在 Docker volume `autosolution_app_upload`(名称前缀随项目目录可能略有不同)。
## 常见问题
- **应用连不上库**:确认 MySQL 健康检查已通过;`init` SQL 是否已执行(空库首次启动才会执行)。
- **Redis 认证失败**:本仓库 `application.yml` 里开发环境 Redis 带密码Compose 中 Redis 默认无密码。若需密码,在 `.env` 设置 `REDIS_PASSWORD`,并确保与 `application-docker.yml` 中 `REDIS_PASSWORD` 环境变量一致(已支持 `${REDIS_PASSWORD}`)。