Files
integral-shop/deploy/docker/step1-integral/README.md
danaisuiyuan fb76270882 feat(deploy): 完整 Docker 部署方案 — 寄卖商城 + 积分商城
新增两步独立 Docker 部署方案(czleilei240 环境):

步骤一 寄卖商城(integral-resell)
- step1-integral/docker-compose.yml:redis(Alpine自建) + houtai(webman PHP8) + h5(Nginx)
- houtai.Dockerfile:PHP 8.0 + 阿里云镜像源 + webman.bin entrypoint
- h5.Dockerfile:Nginx + configs.js 环境变量动态重写
- redis.Dockerfile:Alpine + apk 构建,绕过 DockerHub 镜像源问题
- 宿主机 bind-mount:/www/wwwroot/leileiadmin.czchunfang.com(FTP可直接更新程序)

步骤二 积分商城(single-shop-22)
- step2-single-shop/docker-compose.yml:redis + admin-api + front-api + admin-web + h5
- Java Dockerfiles:OpenJDK 17 + --add-opens Spring Boot 2.2.6 兼容

公共配置
- nginx/:四个域名宝塔 Nginx 反代配置(HTTP→HTTPS 301、SSL 终止)
- scripts/:sync-to-server.sh / deploy-step1.sh / remote-up.sh
- DOCKER_DEPLOY.md:完整部署文档

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-17 17:24:08 +08:00

127 lines
4.3 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 部署(池州雷蕾商贸 czleilei240
项目:`integral-resell`(寄卖商城)
服务:`redis` · `integral-houtai`Webman PHP 8.0)· `integral-h5`Nginx 静态站)
步骤二(积分商城)与本步骤完全独立,可以单独部署、单独重启。
---
## 快速部署
```bash
cd deploy/docker/step1-integral
# 1. 准备环境变量
cp .env.example .env
cp houtai.env.example houtai.env
vim .env # 填入 REDIS_PASSWORD
vim houtai.env # 填入 DB_PASSWORDRDS 密码、REDIS_PASSWORD同 .env
# 2. 首次部署:在服务器上确保宿主机目录存在
# (若原部署目录已存在则跳过)
mkdir -p /www/wwwroot/leilei.czchunfang.com
mkdir -p /www/wwwroot/leileiadmin.czchunfang.com/public/upload
# 3. 将 H5 静态文件同步到宿主机目录(首次 / 每次前端更新后)
rsync -av integral-resell/h5/ /www/wwwroot/leilei.czchunfang.com/
# 4. 构建并启动
docker compose --env-file .env up -d --build
# 5. 查看状态
docker compose --env-file .env ps
docker compose --env-file .env logs -f integral-houtai
```
---
## 目录映射(宿主机 ↔ 容器)
| 宿主机路径 | 容器路径 | 用途 |
|---|---|---|
| `/www/wwwroot/leilei.czchunfang.com` | `/usr/share/nginx/html` | H5 静态文件,手动改 JS 即时生效 |
| `/www/wwwroot/leileiadmin.czchunfang.com/public/upload` | `/app/public/upload` | webman 后台上传文件 |
| `./houtai.env` | `/app/.env` | 运行时配置,只读挂入,不打进镜像 |
| `integral-runtime`named vol| `/app/runtime` | webman PID、session 等运行时数据 |
> **H5 文件更新流程**:直接修改 `/www/wwwroot/leilei.czchunfang.com/` 下的文件(如 JS bundle、configs.js
> Nginx 下次请求时自动读取新文件,**无需重启容器**。
> 仅当 Nginx 配置或镜像本身需要变更时,才需要 `docker compose build integral-h5`。
| 域名 | 用途 | Docker 容器端口 | 宿主机端口 | 宝塔 upstream |
|---|---|---|---|---|
| `leilei.czchunfang.com` | 寄卖商城 H5 | integral-h5:80 | **18080** | `resell_h5` |
| `leileiadmin.czchunfang.com` | 寄卖商城 API / 后台 | integral-houtai:**8785** | **18085** | `resell_api` |
> webman.bin 写死监听 **8785** 端口。
> - H5 容器内部 Nginx 已将 `/api/` 和 `/upload/` 代理到 `integral-houtai:8785`Docker 内网,无需暴露)
> - 宝塔 Nginx 的 `leileiadmin.czchunfang.com` 直连宿主机 **18085**(映射到 webman 8785
---
## 宝塔 Nginx 配置
将以下两个文件内容分别粘贴到宝塔面板对应站点的「配置文件」中:
| 配置文件 | 说明 |
|---|---|
| `deploy/docker/nginx/leilei.czchunfang.com.conf` | H5 站点upstream → 127.0.0.1:18080 |
| `deploy/docker/nginx/leileiadmin.czchunfang.com.conf` | API 站点upstream → 127.0.0.1:18085 |
证书路径(文件已在项目中):
```
deploy/docker/ssl-cert/
leilei.czchunfang.com_cert/nginx/leilei.czchunfang.com.{pem,key}
leileiadmin.czchunfang.com_cert/nginx/leileiadmin.czchunfang.com.{pem,key}
```
---
## 验证
| 地址 | 预期 |
|------|------|
| `https://leilei.czchunfang.com/` | 寄卖商城 H5 首页(生产) |
| `https://leileiadmin.czchunfang.com/api/...` | 寄卖商城 API生产 |
| `http://116.62.83.240:18080/` | H5 直连测试(绕过域名/SSL |
---
## 常用命令
```bash
# 重启 webman
docker compose --env-file .env restart integral-houtai
# 看 webman 日志
docker compose --env-file .env logs -f integral-houtai
# 进入 webman 容器
docker compose --env-file .env exec integral-houtai bash
# 仅重建 H5改了 .env 中的域名参数后)
docker compose --env-file .env build integral-h5
docker compose --env-file .env up -d integral-h5
# 停止(保留卷)
docker compose --env-file .env down
# 停止并删除所有卷(慎用:清空上传图片和 runtime
docker compose --env-file .env down -v
```
---
## 关键一致性检查
| 位置 | 值 |
|---|---|
| `.env` INTEGRAL_API_PUBLIC_URL | `https://leileiadmin.czchunfang.com` |
| `.env` INTEGRAL_H5_PUBLIC_URL | `https://leilei.czchunfang.com/` |
| `.env` INTEGRAL_APP_STR | `ZFyTNQTWEkCBczKzyUDJWE9Ecx260517` |
| `houtai.env` APP_SECRET | **同上** |
| `.env` INTEGRAL_SN_ID | `17533260260517` |
| `h5/static/configs.js` sn_id | **同上** |