From e801ec3bbf8532378bf73c11909f8f4a95656672 Mon Sep 17 00:00:00 2001 From: puke Date: Thu, 29 Jan 2026 08:39:50 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Codespace=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=85=8D=E7=BD=AE=E5=8F=8A=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 8 +++++++ .devcontainer/postCreate.sh | 16 ++++++++++++++ .devcontainer/postStart.sh | 24 +++++++++++++++++++++ scripts/codespace_setup.sh | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/postCreate.sh create mode 100644 .devcontainer/postStart.sh create mode 100644 scripts/codespace_setup.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..54b27df --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "Pixelle-Video Codespace", + "image": "mcr.microsoft.com/devcontainers/python:1-3.11", + "forwardPorts": [8501], + "postCreateCommand": ".devcontainer/postCreate.sh", + "postStartCommand": ".devcontainer/postStart.sh", + "remoteUser": "vscode" +} diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh new file mode 100644 index 0000000..a06501b --- /dev/null +++ b/.devcontainer/postCreate.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "[devcontainer] Running postCreate tasks..." + +cd /workspaces/Pixelle-Video + +if [ -f scripts/codespace_setup.sh ]; then + bash scripts/codespace_setup.sh +fi + +echo "[devcontainer] Installing Python dependencies..." +python -m pip install --upgrade pip +python -m pip install -e . || true + +echo "[devcontainer] postCreate complete. You can start the app with .devcontainer/postStart.sh or let postStart run it automatically." diff --git a/.devcontainer/postStart.sh b/.devcontainer/postStart.sh new file mode 100644 index 0000000..eb02612 --- /dev/null +++ b/.devcontainer/postStart.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "[devcontainer] postStart: launching Pixelle-Video Web UI in background..." +cd /workspaces/Pixelle-Video + +# Start the web UI in background so the forwarded port is ready +nohup bash start_web.sh > /tmp/pixelle_streamlit.log 2>&1 & +echo "[devcontainer] Streamlit started (logs: /tmp/pixelle_streamlit.log)" +WEB_PID=$! +echo "" +echo "Common commands:" +echo "1. View logs:" +echo " tail -f /tmp/pixelle_streamlit.log" +echo "2. Stop service:" +echo " pkill -f 'streamlit run web/app.py'" +echo "3. Restart service:" +echo " pkill -f 'streamlit run web/app.py' && nohup bash start_web.sh > /tmp/pixelle_streamlit.log 2>&1 &" +echo "4. Check port usage:" +echo " lsof -i:8501" +echo "5. View processes:" +echo " ps aux | grep streamlit" +echo "" +echo "For more help, see README or run 'ps aux | grep streamlit'." diff --git a/scripts/codespace_setup.sh b/scripts/codespace_setup.sh new file mode 100644 index 0000000..fba9904 --- /dev/null +++ b/scripts/codespace_setup.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "[codespace-setup] Starting Codespace system setup..." + +export DEBIAN_FRONTEND=noninteractive + +sudo apt-get update -y + +# Install system packages needed by the project (idempotent) +sudo apt-get install -y --no-install-recommends \ + ffmpeg \ + fontconfig \ + fonts-liberation \ + fonts-noto-cjk \ + wget \ + xdg-utils \ + ca-certificates || true + +# Try installing chromium via common package names (some images use different package names) +sudo apt-get install -y --no-install-recommends chromium chromium-driver || true +sudo apt-get install -y --no-install-recommends chromium-browser chromium-driver || true + +echo "[codespace-setup] System packages installation complete. Verifying fonts and chromium..." + +echo "[codespace-setup] Chinese fonts (sample):" +fc-list :lang=zh | head -n 10 || true + +if command -v chromium >/dev/null 2>&1; then + echo "[codespace-setup] chromium -> $(command -v chromium)" +elif command -v chromium-browser >/dev/null 2>&1; then + echo "[codespace-setup] chromium-browser -> $(command -v chromium-browser)" +else + echo "[codespace-setup] Warning: chromium not found in PATH" +fi + +echo "[codespace-setup] Done. Next: install Python deps in postCreate step."