File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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。
910name : Build and deploy OpenBlog
1011
1112on :
1617jobs :
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
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
Original file line number Diff line number Diff line change 33DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
44NAME=" openblog-web"
55
6+ # 映射到宿主机的端口(容器内仍为 80)。默认用偏门端口,避免与宝塔/本机 80、8080 冲突。
7+ # 需要:云安全组与本机防火墙放行该端口。临时改用其他端口:HOST_PORT=xxxxx sh docker.sh
8+ HOST_PORT=" ${HOST_PORT:- 18088} "
9+
610docker stop " $NAME " 2> /dev/null || true
711docker rm " $NAME " 2> /dev/null || true
812docker rmi " $NAME " 2> /dev/null || true
913
1014docker build -t " $NAME " " $DIR "
1115
1216docker 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 \
You can’t perform that action at this time.
0 commit comments