Skip to content

Commit 310fc2e

Browse files
committed
fix(dev): dev 容器入口改用 theme host 替代 Astro dev server
Astro dev server(admin-only) 在 / 无 index.astro 会 404,导致容器健康检查失败崩溃循环。 改为与 prod 对齐启动 theme host(node app/src/theme-host/index.mjs): - 从 /var/lib/vanblog/themes 加载 active theme SSR handler,/admin 路由到 /build/app/dist - 健康检查改为 /__theme_host_health - cleanup/monitor 的 ASTRO_PID 统一为 THEME_HOST_PID - 顶部注释同步更新 - Dockerfile 去掉多余空行
1 parent ba7bf60 commit 310fc2e

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ COPY models.config.mjs /workspace/models.config.mjs
201201
# drifts from the code. See AGENTS.md for the contract.
202202
COPY docs/ /workspace/docs/
203203
COPY AGENTS.md /workspace/AGENTS.md
204-
205204
WORKDIR /workspace
206205
RUN pnpm install --frozen-lockfile
207206

docker/entrypoint.dev.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -e
33

4-
# Dev entrypoint: PocketBase (API) + Astro dev server + Caddy (HTTPS + routing)
4+
# Dev entrypoint: PocketBase (API) + Theme Host (SSR frontend) + Caddy (HTTPS + routing)
55
#
66
# Caddy boots with bootstrap.json, then pb's OnBootstrap hook calls LoadConfig
77
# via admin API to inject full routes. Entrypoint is PID 1, Caddy runs in background.
@@ -41,8 +41,8 @@ wait_for() {
4141
cleanup() {
4242
echo "[vanblog] shutting down..."
4343
kill "$MONITOR_PID" 2>/dev/null || true
44-
kill $PB_PID $ASTRO_PID $CADDY_PID 2>/dev/null || true
45-
wait $PB_PID $ASTRO_PID $CADDY_PID 2>/dev/null || true
44+
kill $PB_PID $THEME_HOST_PID $CADDY_PID 2>/dev/null || true
45+
wait $PB_PID $THEME_HOST_PID $CADDY_PID 2>/dev/null || true
4646
}
4747
trap cleanup EXIT INT TERM
4848

@@ -90,19 +90,23 @@ EOF
9090
chmod 600 /etc/vanblog/agent.env
9191
echo "[vanblog] agent.env written to /etc/vanblog/agent.env (see AGENTS.md §环境)"
9292

93-
# 4. Start Astro dev server (HMR)
94-
echo "[vanblog] starting Astro dev server..."
95-
cd /workspace
96-
pnpm --filter vanblog-app dev -- --host 127.0.0.1 --port 4321 &
97-
ASTRO_PID=$!
98-
wait_for "http://127.0.0.1:4321/" "Astro SSR" 30 || exit 1
93+
# 4. Start Theme Host (loads active theme's SSR handler, routes /admin to app)
94+
DEFAULT_THEME=$(cat /etc/vanblog/default-theme 2>/dev/null || echo "vanblog")
95+
echo "[vanblog] starting theme host (default theme: ${DEFAULT_THEME})"
96+
VANBLOG_THEMES_DIR=/var/lib/vanblog/themes \
97+
VANBLOG_DEFAULT_THEME=${DEFAULT_THEME} \
98+
VANBLOG_ADMIN_DIST_DIR=/build/app/dist \
99+
PB_URL=http://127.0.0.1:8090 \
100+
node /workspace/app/src/theme-host/index.mjs &
101+
THEME_HOST_PID=$!
102+
wait_for "http://127.0.0.1:4321/__theme_host_health" "Theme Host" 30 || exit 1
99103

100104
# 5. Background monitor: if any child crashes, kill the container
101105
monitor_children() {
102106
while true; do
103107
if ! kill -0 $CADDY_PID 2>/dev/null; then echo "[vanblog] FATAL: Caddy died"; exit 1; fi
104108
if ! kill -0 $PB_PID 2>/dev/null; then echo "[vanblog] FATAL: PocketBase died"; exit 1; fi
105-
if ! kill -0 $ASTRO_PID 2>/dev/null; then echo "[vanblog] FATAL: Astro died"; exit 1; fi
109+
if ! kill -0 $THEME_HOST_PID 2>/dev/null; then echo "[vanblog] FATAL: Theme Host died"; exit 1; fi
106110
sleep 5
107111
done
108112
}

0 commit comments

Comments
 (0)