Merge pull request #1037 from marcinolek/main

fix: debian_install.sh regression after uv migration (pip-less venv + missing gunicorn)
This commit is contained in:
SergeantPanda 2026-02-27 22:27:26 -06:00 committed by GitHub
commit ac28d05dbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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" <<EOSU
cd "$APP_DIR"
export PATH="\$HOME/.local/bin:\$PATH"
# Install UV for the dispatch user if not already available
if ! command -v uv &> /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" <<EOSU
set -euo pipefail
cd "$APP_DIR"
touch .env
chmod 600 .env
if ! grep -q '^DJANGO_SECRET_KEY=' .env; then
key=\$(env/bin/python - <<'PY'
import secrets
print(secrets.token_urlsafe(64))
PY
)
echo "DJANGO_SECRET_KEY=\$key" >> .env
fi
EOSU
}
##############################################################################
# 7) Build Frontend
##############################################################################
@ -231,17 +258,21 @@ create_directories() {
django_migrate_collectstatic() {
echo ">>> Running Django migrations & collectstatic..."
su - "$DISPATCH_USER" <<EOSU
set -euo pipefail
cd "$APP_DIR"
source env/bin/activate
set -a
source .env
set +a
export POSTGRES_DB="$POSTGRES_DB"
export POSTGRES_USER="$POSTGRES_USER"
export POSTGRES_PASSWORD="$POSTGRES_PASSWORD"
export POSTGRES_HOST="localhost"
python manage.py migrate --noinput
python manage.py collectstatic --noinput
env/bin/python manage.py migrate --noinput
env/bin/python manage.py collectstatic --noinput
EOSU
}
##############################################################################
# 10) Configure Services & Nginx
##############################################################################
@ -261,6 +292,7 @@ Group=${DISPATCH_GROUP}
WorkingDirectory=${APP_DIR}
RuntimeDirectory=${GUNICORN_RUNTIME_DIR}
RuntimeDirectoryMode=0775
EnvironmentFile=/opt/dispatcharr/.env
Environment="PATH=${APP_DIR}/env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
Environment="POSTGRES_DB=${POSTGRES_DB}"
Environment="POSTGRES_USER=${POSTGRES_USER}"
@ -293,6 +325,7 @@ Requires=dispatcharr.service
User=${DISPATCH_USER}
Group=${DISPATCH_GROUP}
WorkingDirectory=${APP_DIR}
EnvironmentFile=/opt/dispatcharr/.env
Environment="PATH=${APP_DIR}/env/bin"
Environment="POSTGRES_DB=${POSTGRES_DB}"
Environment="POSTGRES_USER=${POSTGRES_USER}"
@ -320,6 +353,7 @@ Requires=dispatcharr.service
User=${DISPATCH_USER}
Group=${DISPATCH_GROUP}
WorkingDirectory=${APP_DIR}
EnvironmentFile=/opt/dispatcharr/.env
Environment="PATH=${APP_DIR}/env/bin"
Environment="POSTGRES_DB=${POSTGRES_DB}"
Environment="POSTGRES_USER=${POSTGRES_USER}"
@ -347,6 +381,7 @@ Requires=dispatcharr.service
User=${DISPATCH_USER}
Group=${DISPATCH_GROUP}
WorkingDirectory=${APP_DIR}
EnvironmentFile=/opt/dispatcharr/.env
Environment="PATH=${APP_DIR}/env/bin"
Environment="POSTGRES_DB=${POSTGRES_DB}"
Environment="POSTGRES_USER=${POSTGRES_USER}"
@ -448,6 +483,7 @@ main() {
setup_python_env
build_frontend
create_directories
ensure_env_file
django_migrate_collectstatic
configure_services
start_services