Skip to content

Commit b603130

Browse files
committed
Reapply "v 1.0.7 添加前端自动部署"
This reverts commit 617f109.
1 parent e382701 commit b603130

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# SERVER_TARGET 服务器上部署目录绝对路径(如 /opt/openblog/web),该目录下会有 dist、Dockerfile、docker.sh、nginx.conf
77
#
88
# 后端 Spring Boot 需在**同一台机器宿主机**上监听 8082(java -jar 或 systemd),容器内 Nginx 通过 host.docker.internal 反代到宿主机。
9+
# 前端容器默认映射宿主机端口 18088 → 容器 80,访问 http://IP:18088/ ,请在安全组放行 TCP 18088。
910
name: Build and deploy OpenBlog
1011

1112
on:
@@ -16,6 +17,10 @@ on:
1617
jobs:
1718
build-and-deploy:
1819
runs-on: ubuntu-latest
20+
# 消除 “Node.js 20 actions are deprecated” 警告:让基于 JS 的 action 在 Node 24 上跑
21+
# 见 https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
22+
env:
23+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1924

2025
steps:
2126
- name: Checkout
@@ -34,7 +39,7 @@ jobs:
3439
- name: Set up Node.js
3540
uses: actions/setup-node@v4
3641
with:
37-
node-version: "20"
42+
node-version: "22"
3843
cache: "npm"
3944
cache-dependency-path: frontend/package-lock.json
4045

frontend/docker.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ set -e
33
DIR="$(cd "$(dirname "$0")" && pwd)"
44
NAME="openblog-web"
55

6+
# 映射到宿主机的端口(容器内仍为 80)。默认用偏门端口,避免与宝塔/本机 80、8080 冲突。
7+
# 需要:云安全组与本机防火墙放行该端口。临时改用其他端口:HOST_PORT=xxxxx sh docker.sh
8+
HOST_PORT="${HOST_PORT:-18088}"
9+
610
docker stop "$NAME" 2>/dev/null || true
711
docker rm "$NAME" 2>/dev/null || true
812
docker rmi "$NAME" 2>/dev/null || true
913

1014
docker build -t "$NAME" "$DIR"
1115

1216
docker run -d \
13-
-p 80:80 \
17+
-p "${HOST_PORT}:80" \
1418
--name "$NAME" \
1519
--add-host=host.docker.internal:host-gateway \
1620
--restart on-failure:5 \

0 commit comments

Comments
 (0)