diff --git a/debian_install.sh b/debian_install.sh index 3452e5c1..3630161d 100755 --- a/debian_install.sh +++ b/debian_install.sh @@ -168,24 +168,51 @@ install_uv() { setup_python_env() { echo ">>> Setting up Python virtual environment with UV..." - # Install UV globally first - install_uv su - "$DISPATCH_USER" < /dev/null; then - curl -LsSf https://astral.sh/uv/install.sh | sh + set -euo pipefail + cd "$APP_DIR" export PATH="\$HOME/.local/bin:\$PATH" -fi -# Create venv and install dependencies using UV -uv venv env --python $PYTHON_BIN -uv sync --python env/bin/python --no-install-project --no-dev + + command -v uv >/dev/null 2>&1 || curl -LsSf https://astral.sh/uv/install.sh | sh + + rm -rf env + $PYTHON_BIN -m venv env + env/bin/python -m ensurepip --upgrade + + export UV_PROJECT_ENVIRONMENT="$APP_DIR/env" + uv sync --no-dev + + env/bin/python -m pip install -q gunicorn EOSU + ln -sf /usr/bin/ffmpeg "$APP_DIR/env/bin/ffmpeg" } + +############################################################################## +# 6.1) Ensure Environment File +############################################################################## + +ensure_env_file() { + echo ">>> Ensuring DJANGO_SECRET_KEY exists in ${APP_DIR}/.env..." + su - "$DISPATCH_USER" <> .env +fi +EOSU +} + + ############################################################################## # 7) Build Frontend ############################################################################## @@ -231,17 +258,21 @@ create_directories() { django_migrate_collectstatic() { echo ">>> Running Django migrations & collectstatic..." su - "$DISPATCH_USER" <