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."