feat(deploy): configure czleilei240 integral shop

Add czleilei240 runtime profiles, frontend domains, contract paths, and Docker deployment updates so the integral shop can run against the Leilei environment.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
danaisuiyuan
2026-05-17 19:13:01 +08:00
parent fb76270882
commit cef4398a5a
23 changed files with 448 additions and 287 deletions

View File

@@ -1,50 +1,24 @@
# =============================================================
# 寄卖商城 用户端 H5 uni-app
# build context = single-shop-22/single_uniapp22miao
# 多阶段: Node 构建 H5 -> Nginx 运行
# 通过 ARG H5_API_DOMAIN 注入 API 域名(留空走同域 /api/
#
# 直接复用源码已构建产物: 用 --target=fast 构建
# 积分商城 用户端 H5uni-app SPA
# 纯 Nginx 运行时镜像,不含 Node 构建阶段
# 静态文件由宿主机 bind-mount 进来(${SINGLE_H5_DIR}:/usr/share/nginx/html
# 宿主机目录示例:/www/wwwroot/leilei-jf.czchunfang.com/
# 更新方式rsync 新 dist 到宿主机目录 → 无需重建镜像
# =============================================================
# syntax=docker/dockerfile:1.6
# ---------- 构建阶段 ----------
FROM node:16-alpine AS builder
ARG H5_API_DOMAIN=""
ENV NODE_OPTIONS=--openssl-legacy-provider \
NPM_CONFIG_REGISTRY=https://registry.npmmirror.com
FROM nginx:1.25-alpine
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install --legacy-peer-deps
COPY . .
# 重写 config/app.js 中的 domain
# 留空时使用同域: let domain = ''
RUN sed -i -E "s|^let[[:space:]]+domain[[:space:]]*=.*|let domain = '${H5_API_DOMAIN}'|" config/app.js \
&& sed -i -E "s|HTTP_H5_URL:[[:space:]]*'[^']*'|HTTP_H5_URL: '${H5_API_DOMAIN}'|" config/app.js \
&& cat config/app.js
RUN npm run build:h5
# uni-app 默认产物路径
# unpackage/dist/build/h5 Vue CLI Plugin uni 旧版: unpackage/dist/build/web
# ---------- 运行阶段 ----------
FROM nginx:1.25-alpine AS runtime
ENV TZ=Asia/Shanghai
RUN apk add --no-cache tzdata \
# 切换阿里云 Alpine 镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
&& apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
COPY --from=builder /app/unpackage/dist/build/ /tmp/h5build/
# 兼容两种输出目录名 h5/ 或 web/
RUN if [ -d /tmp/h5build/h5 ]; then cp -r /tmp/h5build/h5/. /usr/share/nginx/html/; \
elif [ -d /tmp/h5build/web ]; then cp -r /tmp/h5build/web/. /usr/share/nginx/html/; \
else echo "未找到 h5 / web 产物"; exit 1; fi \
&& rm -rf /tmp/h5build
&& echo $TZ > /etc/timezone \
&& rm -f /etc/apk/cache/*.apk
# Nginx 反代配置
# API 请求代理到 single-front-api 容器Docker 内网,不经宝塔 Nginx
RUN cat > /etc/nginx/conf.d/default.conf <<'NGX'
server {
listen 80;
@@ -60,8 +34,9 @@ server {
try_files $uri =404;
}
# 前台 API单点登录/商品/订单等)
location /api/ {
proxy_pass http://single-front-api:30031/api/;
proxy_pass http://single-front-api:30033/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -78,19 +53,3 @@ server {
NGX
EXPOSE 80
# ---------- 备选: 直接复用源码已构建的 unpackage/dist/build/h5 ----------
# 构建: docker compose build --target fast single-h5
FROM nginx:1.25-alpine AS fast
ENV TZ=Asia/Shanghai
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
COPY unpackage/dist/build/ /tmp/h5build/
RUN if [ -d /tmp/h5build/h5 ]; then cp -r /tmp/h5build/h5/. /usr/share/nginx/html/; \
elif [ -d /tmp/h5build/web ]; then cp -r /tmp/h5build/web/. /usr/share/nginx/html/; \
else echo "未找到 h5 / web 产物"; exit 1; fi \
&& rm -rf /tmp/h5build
COPY --from=runtime /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80