diff --git a/apps/mini-user/config/index.ts b/apps/mini-user/config/index.ts index 9ab49b6..51b5602 100644 --- a/apps/mini-user/config/index.ts +++ b/apps/mini-user/config/index.ts @@ -63,7 +63,11 @@ export default defineConfig(async () => ({ }, }, h5: { - publicPath: '/', + publicPath: process.env.TARO_H5_PUBLIC_PATH || '/', + router: { + mode: 'browser', + basename: process.env.TARO_H5_ROUTER_BASENAME || '/', + }, staticDirectory: 'static', devServer: { port: 5177, diff --git a/deploy/auto-release.env.example b/deploy/auto-release.env.example index 18fa72d..687c8e4 100644 --- a/deploy/auto-release.env.example +++ b/deploy/auto-release.env.example @@ -2,6 +2,7 @@ # 服务器路径: /opt/dukang-haoke/deploy/auto-release.env APP_ROOT=/opt/dukang-haoke +GIT_REPO_URL=git@git.yqidian.com:jacy/dukang.git GIT_REMOTE=origin GIT_BRANCH=dev DEPLOY_GIT_REF=refs/heads/dev diff --git a/deploy/auto-release.sh b/deploy/auto-release.sh index 0612018..f85b78b 100644 --- a/deploy/auto-release.sh +++ b/deploy/auto-release.sh @@ -45,6 +45,15 @@ if [[ ! -d .git ]]; then exit 1 fi +# 统一远程仓库为 SSH 地址 +GIT_REPO_URL="${GIT_REPO_URL:-git@git.yqidian.com:jacy/dukang.git}" +CURRENT_URL="$(git remote get-url "$GIT_REMOTE" 2>/dev/null || true)" +if [[ "$CURRENT_URL" != "$GIT_REPO_URL" ]]; then + log "SET remote $GIT_REMOTE -> $GIT_REPO_URL (was: ${CURRENT_URL:-none})" + git remote set-url "$GIT_REMOTE" "$GIT_REPO_URL" 2>/dev/null \ + || git remote add "$GIT_REMOTE" "$GIT_REPO_URL" +fi + git fetch "$GIT_REMOTE" git checkout "$GIT_BRANCH" diff --git a/deploy/deploy.env.example b/deploy/deploy.env.example index 5c3b985..3bf492e 100644 --- a/deploy/deploy.env.example +++ b/deploy/deploy.env.example @@ -5,5 +5,7 @@ DEPLOY_PORT=22 # DEPLOY_SSH_KEY=~/.ssh/id_rsa APP_ROOT=/opt/dukang-haoke +# 生产仓库(SSH) +GIT_REPO_URL=git@git.yqidian.com:jacy/dukang.git GIT_REMOTE=origin GIT_BRANCH=dev diff --git a/deploy/ecosystem.config.cjs b/deploy/ecosystem.config.cjs index e9502cf..63dec18 100644 --- a/deploy/ecosystem.config.cjs +++ b/deploy/ecosystem.config.cjs @@ -15,8 +15,9 @@ module.exports = { }, }, { + // C 端改为 mini-user H5 产物(端口仍 8091,进程名保持兼容旧脚本) name: 'dukang-h5-user', - cwd: `${APP_ROOT}/apps/h5-user`, + cwd: `${APP_ROOT}/apps/mini-user`, script: 'npx', args: 'serve -s dist -l 8091', interpreter: 'none', diff --git a/deploy/nginx-runxian-dukang-ssl.conf b/deploy/nginx-runxian-dukang-ssl.conf index 3b854fa..30c87fb 100644 --- a/deploy/nginx-runxian-dukang-ssl.conf +++ b/deploy/nginx-runxian-dukang-ssl.conf @@ -42,7 +42,7 @@ server { client_max_body_size 20m; location ~ ^/MP_verify_.*\.txt$ { - root /opt/dukang-haoke/apps/h5-user/dist; + root /opt/dukang-haoke/apps/mini-user/dist; default_type text/plain; access_log off; } diff --git a/deploy/nginx-runxian-dukang.conf b/deploy/nginx-runxian-dukang.conf index a0e623c..241857a 100644 --- a/deploy/nginx-runxian-dukang.conf +++ b/deploy/nginx-runxian-dukang.conf @@ -17,7 +17,7 @@ server { } location ~ ^/MP_verify_.*\.txt$ { - root /opt/dukang-haoke/apps/h5-user/dist; + root /opt/dukang-haoke/apps/mini-user/dist; default_type text/plain; access_log off; } diff --git a/deploy/remote-release.sh b/deploy/remote-release.sh index ef64231..cf3e4e3 100644 --- a/deploy/remote-release.sh +++ b/deploy/remote-release.sh @@ -41,7 +41,11 @@ corepack enable 2>/dev/null || true corepack prepare pnpm@11.2.2 --activate 2>/dev/null || true echo "==> 2. 安装依赖" -export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=2048}" +# mini-user H5(Taro)构建峰值内存较高 +export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=8192}" +# 生产部署 path:nginx 入口为 /user/ +export TARO_H5_PUBLIC_PATH="${TARO_H5_PUBLIC_PATH:-/user/}" +export TARO_H5_ROUTER_BASENAME="${TARO_H5_ROUTER_BASENAME:-/user}" pnpm approve-builds --all 2>/dev/null || true pnpm install --frozen-lockfile 2>/dev/null || pnpm install @@ -68,16 +72,26 @@ else fi if [[ "$SKIP_BUILD" == false ]]; then - echo "==> 4. 构建" - pnpm build + echo "==> 4. 构建(C 端使用 mini-user H5,跳过 h5-user)" + pnpm --filter @dukang/shared-types \ + --filter @dukang/domain \ + --filter @dukang/api \ + --filter @dukang/mini-user \ + --filter @dukang/h5-shop \ + --filter @dukang/h5-partner \ + --filter @dukang/admin-web \ + build else echo "==> 4. 跳过构建" fi echo "==> 5. 重启 PM2" if pm2 describe dukang-api &>/dev/null; then - pm2 restart dukang-api dukang-h5-user dukang-h5-shop dukang-h5-partner dukang-admin-web 2>/dev/null \ - || pm2 restart dukang-api dukang-h5-user dukang-h5-shop dukang-h5-partner + # delete+start 以确保 cwd 从 h5-user 切到 mini-user + pm2 delete dukang-h5-user 2>/dev/null || true + pm2 start "$DEPLOY_DIR/ecosystem.config.cjs" --only dukang-h5-user + pm2 restart dukang-api dukang-h5-shop dukang-h5-partner dukang-admin-web 2>/dev/null \ + || pm2 restart dukang-api dukang-h5-shop dukang-h5-partner else pm2 start "$DEPLOY_DIR/ecosystem.config.cjs" fi @@ -86,8 +100,8 @@ pm2 save echo "==> 6. 健康检查" sleep 2 pm2 list -ss -tlnp | grep -E '809[0-3]' || true -curl -sf -o /dev/null -w "h5-user: %{http_code}\n" http://127.0.0.1:8091/ || echo "h5-user: FAIL" +ss -tlnp | grep -E '809[0-4]' || true +curl -sf -o /dev/null -w "mini-user(h5): %{http_code}\n" http://127.0.0.1:8091/ || echo "mini-user(h5): FAIL" curl -sf -o /dev/null -w "api: %{http_code}\n" http://127.0.0.1:8090/api/v1/health 2>/dev/null \ || curl -sf -o /dev/null -w "api: %{http_code}\n" http://127.0.0.1:8090/ \ || echo "api: FAIL"