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>
This commit is contained in:
31
deploy/docker/step1-integral/.env.example
Normal file
31
deploy/docker/step1-integral/.env.example
Normal file
@@ -0,0 +1,31 @@
|
||||
# =============================================================
|
||||
# 步骤一:寄卖商城环境变量 — 池州雷蕾商贸 czleilei240
|
||||
# cp .env.example .env 并填入真实密码
|
||||
# .env 不入库
|
||||
# =============================================================
|
||||
|
||||
TZ=Asia/Shanghai
|
||||
|
||||
# ---------- Redis(容器内) ----------
|
||||
REDIS_PASSWORD=change-me-redis
|
||||
|
||||
# ---------- H5 对外域名(浏览器可达) ----------
|
||||
INTEGRAL_TITLE=池州雷蕾商贸
|
||||
INTEGRAL_API_PUBLIC_URL=https://leileiadmin.czchunfang.com
|
||||
INTEGRAL_IMG_PUBLIC_URL=https://leileiadmin.czchunfang.com
|
||||
INTEGRAL_H5_PUBLIC_URL=https://leilei.czchunfang.com/
|
||||
INTEGRAL_SN_ID=17533260260517
|
||||
INTEGRAL_APP_STR=ZFyTNQTWEkCBczKzyUDJWE9Ecx260517
|
||||
INTEGRAL_CONTRACT_PAGE=10012
|
||||
|
||||
# ---------- 宿主机暴露端口 ----------
|
||||
INTEGRAL_H5_PORT=18080
|
||||
# webman API 直连端口(宝塔 Nginx leileiadmin.czchunfang.com → 此端口)
|
||||
RESELL_API_PORT=18085
|
||||
|
||||
# ---------- 宿主机目录映射(bind mount,与原部署路径一致)----------
|
||||
# 寄卖商城 H5 静态文件目录(手动改 JS/configs.js 直接生效,无需重建镜像)
|
||||
RESELL_H5_DIR=/www/wwwroot/leilei.czchunfang.com
|
||||
# webman 后台完整应用目录(FTP 上传新 webman.bin/public/ 后 restart 容器即可更新)
|
||||
# 上传图片、public/upload 等均包含在此目录内,无需单独挂载
|
||||
RESELL_HOUTAI_DIR=/www/wwwroot/leileiadmin.czchunfang.com
|
||||
2
deploy/docker/step1-integral/.gitignore
vendored
Normal file
2
deploy/docker/step1-integral/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
houtai.env
|
||||
126
deploy/docker/step1-integral/README.md
Normal file
126
deploy/docker/step1-integral/README.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# 步骤一:寄卖商城 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_PASSWORD(RDS 密码)、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 | **同上** |
|
||||
95
deploy/docker/step1-integral/docker-compose.yml
Normal file
95
deploy/docker/step1-integral/docker-compose.yml
Normal file
@@ -0,0 +1,95 @@
|
||||
# =============================================================
|
||||
# 步骤一:寄卖商城(integral-resell)独立部署
|
||||
# 客户:池州雷蕾商贸 czleilei240
|
||||
# 包含服务:redis · integral-houtai(webman) · integral-h5(Nginx)
|
||||
# =============================================================
|
||||
|
||||
name: resell-czleilei240
|
||||
|
||||
x-common: &common
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: ${TZ:-Asia/Shanghai}
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "20m"
|
||||
max-file: "5"
|
||||
|
||||
networks:
|
||||
integral-net:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
integral-redis-data:
|
||||
integral-runtime:
|
||||
|
||||
services:
|
||||
# ---------- Redis ----------
|
||||
redis:
|
||||
<<: *common
|
||||
build:
|
||||
context: .
|
||||
dockerfile: redis.Dockerfile
|
||||
image: resell-czleilei240/redis:local
|
||||
container_name: integral-redis
|
||||
command: ["--requirepass", "${REDIS_PASSWORD}", "--appendonly", "yes"]
|
||||
volumes:
|
||||
- integral-redis-data:/data
|
||||
networks: [integral-net]
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
# ---------- Webman 后端 ----------
|
||||
integral-houtai:
|
||||
<<: *common
|
||||
build:
|
||||
context: ../../../integral-resell/houtai
|
||||
dockerfile: ../../deploy/docker/integral-resell/houtai.Dockerfile
|
||||
image: resell-czleilei240/houtai:latest
|
||||
container_name: integral-houtai
|
||||
networks: [integral-net]
|
||||
ports:
|
||||
# 宝塔 Nginx 直连 webman API(webman.bin 写死监听 8785)
|
||||
- "${RESELL_API_PORT:-18085}:8785"
|
||||
volumes:
|
||||
# 整个应用目录挂到宿主机 /www/wwwroot/leileiadmin.czchunfang.com/
|
||||
# FTP 上传新 webman.bin / public/ 后 docker compose restart integral-houtai 即可生效
|
||||
- ${RESELL_HOUTAI_DIR}:/app
|
||||
# .env 单独挂入(覆盖宿主机目录里的 .env),避免明文密码出现在 wwwroot
|
||||
- ./houtai.env:/app/.env:ro
|
||||
# runtime 使用命名卷(日志/session/pid 不受 FTP 覆盖影响)
|
||||
- integral-runtime:/app/runtime
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
|
||||
# ---------- H5 静态站 ----------
|
||||
integral-h5:
|
||||
<<: *common
|
||||
build:
|
||||
context: ../../../integral-resell/h5
|
||||
dockerfile: ../../deploy/docker/integral-resell/h5.Dockerfile
|
||||
image: resell-czleilei240/h5:latest
|
||||
container_name: integral-h5
|
||||
networks: [integral-net]
|
||||
environment:
|
||||
TZ: ${TZ:-Asia/Shanghai}
|
||||
INTEGRAL_TITLE: ${INTEGRAL_TITLE}
|
||||
INTEGRAL_API_PUBLIC_URL: ${INTEGRAL_API_PUBLIC_URL}
|
||||
INTEGRAL_IMG_PUBLIC_URL: ${INTEGRAL_IMG_PUBLIC_URL}
|
||||
INTEGRAL_H5_PUBLIC_URL: ${INTEGRAL_H5_PUBLIC_URL}
|
||||
INTEGRAL_SN_ID: ${INTEGRAL_SN_ID}
|
||||
INTEGRAL_APP_STR: ${INTEGRAL_APP_STR}
|
||||
INTEGRAL_CONTRACT_PAGE: ${INTEGRAL_CONTRACT_PAGE}
|
||||
volumes:
|
||||
# H5 静态文件目录挂到宿主机,手动更新 JS/configs.js 直接生效,无需重建镜像
|
||||
# 子目录 crmebimage/ 同时由步骤二 Java 后端写入(PDF/图片),Nginx 直接对外提供访问
|
||||
- ${RESELL_H5_DIR}:/usr/share/nginx/html
|
||||
ports:
|
||||
- "${INTEGRAL_H5_PORT:-18080}:80"
|
||||
depends_on:
|
||||
- integral-houtai
|
||||
37
deploy/docker/step1-integral/houtai.env.example
Normal file
37
deploy/docker/step1-integral/houtai.env.example
Normal file
@@ -0,0 +1,37 @@
|
||||
# =============================================================
|
||||
# Webman 后端运行时配置 — 池州雷蕾商贸 czleilei240(寄卖商城)
|
||||
# cp houtai.env.example houtai.env 并填入真实密码
|
||||
# houtai.env 不入库,由 docker-compose volumes: 挂入 /app/.env
|
||||
# =============================================================
|
||||
|
||||
# MySQL(阿里云 RDS)
|
||||
DB_HOST = 'rm-bp1a178eq62lxba9xbo.mysql.rds.aliyuncs.com'
|
||||
DB_PORT = 3306
|
||||
DB_DATABASE = 'yangtangyoupin'
|
||||
DB_USERNAME = 'yangtangyoupin'
|
||||
DB_PASSWORD = 'change-me'
|
||||
|
||||
# Redis(指向同 compose 内的 redis 容器)
|
||||
REDIS_HOST = 'redis'
|
||||
REDIS_PORT = 6379
|
||||
REDIS_PASSWORD = 'change-me-redis'
|
||||
|
||||
# 短信(池州雷蕾商贸专属通道)
|
||||
SMS_CHANNEL = 'alibaba'
|
||||
SMS_SIGNNAME = '池州雷蕾商贸'
|
||||
SMS_TEMPLATE = 'SMS_334320185'
|
||||
SMS_KEYID = 'LTAI5t7CfS15hZGdNLLEMUwG'
|
||||
SMS_KEYSECRET = 'ikfTvHbMMg5sStGgdvLNL8iuVYdner'
|
||||
SMS_SDKAPPID = ''
|
||||
|
||||
# OSS(不启用则走本地 public/upload)
|
||||
FILE_STORAGE = 'public'
|
||||
OSS_ACCESS_ID = ''
|
||||
OSS_ACCESS_SECRET = ''
|
||||
OSS_BUCKET = ''
|
||||
OSS_ENDPOINT = ''
|
||||
OSS_URL = ''
|
||||
|
||||
# 业务标识(须与 H5 configs.js 的 sn_id / appStr 以及积分商城 admin 后台一致)
|
||||
APP_SIGN = '1'
|
||||
APP_SECRET = 'ZFyTNQTWEkCBczKzyUDJWE9Ecx260517'
|
||||
13
deploy/docker/step1-integral/redis.Dockerfile
Normal file
13
deploy/docker/step1-integral/redis.Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
# 使用 Alpine 通过 apk 安装 Redis,绕过镜像源问题
|
||||
FROM alpine:3.19
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache redis tzdata \
|
||||
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
VOLUME /data
|
||||
WORKDIR /data
|
||||
EXPOSE 6379
|
||||
|
||||
ENTRYPOINT ["redis-server"]
|
||||
Reference in New Issue
Block a user