diff --git a/.devcontainer/bin/ui b/.devcontainer/bin/ui index 7f8e79b0c..03ec142a9 100755 --- a/.devcontainer/bin/ui +++ b/.devcontainer/bin/ui @@ -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 diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index f3a30b40d..de448dadf 100755 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -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 …"