nice
This commit is contained in:
parent
9e7dbab52e
commit
abc6871062
49
start.sh
49
start.sh
@ -70,14 +70,49 @@ export BACKEND_PROXY_HOST=127.0.0.1
|
|||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
cd /home/container/backend
|
cd /home/container/backend
|
||||||
|
|
||||||
python3 -m pip install -r requirements.txt
|
# Pterodactyl : le systeme Python du conteneur peut etre en lecture seule.
|
||||||
python3 manage.py check
|
# Installer les dependances dans /home/container (persistant et inscriptible),
|
||||||
python3 manage.py migrate --noinput
|
# jamais dans les site-packages systeme.
|
||||||
python3 manage.py ensure_admin
|
PYTHON_BIN="python3"
|
||||||
python3 manage.py collectstatic --noinput --verbosity 0
|
VENV_DIR="/home/container/.venv"
|
||||||
|
|
||||||
echo "Démarrage Django sur :${BACKEND_PORT}"
|
if [[ -x "$VENV_DIR/bin/python" ]] && "$VENV_DIR/bin/python" -m pip --version >/dev/null 2>&1; then
|
||||||
python3 manage.py runserver "0.0.0.0:${BACKEND_PORT}" --noreload &
|
PYTHON_BIN="$VENV_DIR/bin/python"
|
||||||
|
else
|
||||||
|
# Nettoie un eventuel venv incomplet (ex. ensurepip absent).
|
||||||
|
rm -rf -- "$VENV_DIR"
|
||||||
|
echo "Creation de l'environnement Python dans $VENV_DIR..."
|
||||||
|
if python3 -m venv --system-site-packages "$VENV_DIR" \
|
||||||
|
&& "$VENV_DIR/bin/python" -m pip --version >/dev/null 2>&1; then
|
||||||
|
PYTHON_BIN="$VENV_DIR/bin/python"
|
||||||
|
else
|
||||||
|
# Certaines images Pterodactyl ne contiennent pas le module venv.
|
||||||
|
# pip --target fonctionne sans droits root ni ecriture dans /usr/local.
|
||||||
|
echo "venv indisponible : installation locale avec pip --target."
|
||||||
|
DEPS_DIR="/home/container/.python-deps"
|
||||||
|
mkdir -p "$DEPS_DIR"
|
||||||
|
export PYTHONPATH="$DEPS_DIR${PYTHONPATH:+:$PYTHONPATH}"
|
||||||
|
PYTHON_BIN="python3"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$PYTHON_BIN" == "python3" ]]; then
|
||||||
|
# Repli pour les images sans venv : repertorie accessible en ecriture.
|
||||||
|
echo "Installation des dependances Python dans /home/container/.python-deps..."
|
||||||
|
python3 -m pip install --disable-pip-version-check --no-cache-dir \
|
||||||
|
--target /home/container/.python-deps --upgrade -r requirements.txt
|
||||||
|
else
|
||||||
|
echo "Installation / verification des dependances dans le venv local..."
|
||||||
|
"$PYTHON_BIN" -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$PYTHON_BIN" manage.py check
|
||||||
|
"$PYTHON_BIN" manage.py migrate --noinput
|
||||||
|
"$PYTHON_BIN" manage.py ensure_admin
|
||||||
|
"$PYTHON_BIN" manage.py collectstatic --noinput --verbosity 0
|
||||||
|
|
||||||
|
echo "Demarrage Django sur :${BACKEND_PORT}"
|
||||||
|
"$PYTHON_BIN" manage.py runserver "0.0.0.0:${BACKEND_PORT}" --noreload &
|
||||||
BACKEND_PID=$!
|
BACKEND_PID=$!
|
||||||
|
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user