feat: integrate air hot-reload into devcontainer

Replace manual build+nohup with air in the `ui` command and install
air during setup so .go changes auto-restart the API server.
This commit is contained in:
Willie
2026-02-23 04:18:01 +08:00
parent 9700474c0f
commit 1637b1905f
2 changed files with 12 additions and 13 deletions
+6 -11
View File
@@ -71,21 +71,16 @@ for _ in 1 2 3 4 5 6; do
sleep 0.5
done
# Build binary.
printf " %-12s building..." "api"
if ! (cd /workspace && /usr/local/go/bin/go build -o /tmp/skillshare-dev ./cmd/skillshare) 2>"$LOGDIR/ui-build.log"; then
echo " failed (see $LOGDIR/ui-build.log)"
exit 1
fi
echo " ok"
# Start API.
# Start API via air (hot-reload).
export SKILLSHARE_UI_HOST=0.0.0.0
MODE_FLAG="-${MODE:0:1}"
export SKILLSHARE_UI_FLAGS="${MODE_FLAG} --port ${PORT}"
if [ "$MODE" = "project" ]; then
cd ~/demo-project
fi
nohup /tmp/skillshare-dev ui "-${MODE:0:1}" --no-open --host 0.0.0.0 --port $PORT > "$LOGDIR/api-dev.log" 2>&1 &
nohup /usr/local/go/bin/air -c /workspace/.air.toml > "$LOGDIR/api-dev.log" 2>&1 &
echo $! > "$PIDDIR/api.pid"
printf " %-12s started (%s mode)\n" "api" "$MODE"
printf " %-12s started (%s mode, hot-reload)\n" "api" "$MODE"
# Ensure Vite is running.
if is_port_open $VITE_PORT; then
+6 -2
View File
@@ -27,11 +27,15 @@ PROFILE_EOF
echo "▸ Building skillshare binary …"
make build
# ── 1a. Ensure Linux binary + stable command symlinks ─────────────
# ── 1a. Install air (Go hot-reload) ─────────────────────────────
echo "▸ Installing air (hot-reload) …"
go install github.com/air-verse/air@latest
# ── 1b. Ensure Linux binary + stable command symlinks ─────────────
echo "▸ Verifying skillshare command targets …"
./.devcontainer/ensure-skillshare-linux-binary.sh
# ── 1b. Install frontend dependencies ─────────────────────────────
# ── 1c. Install frontend dependencies ─────────────────────────────
echo "▸ Installing UI dependencies …"
(cd /workspace/ui && pnpm install --frozen-lockfile)
echo "▸ Installing website dependencies …"