2026-09-13 19:05:48 +02:00

89 lines
1.8 KiB
Bash

#!/bin/bash
set -e
cd /home/container
echo "======================================"
echo " Boulangerie Web"
echo "======================================"
# --------------------------------------
# Mise à jour du projet
# --------------------------------------
if [ ! -d ".git" ]; then
echo "Dépôt Git absent → clonage..."
git clone https://gitea.louismazin.ovh/LouisMazin/Boulangerie_Website.git /tmp/boulangerie
cp -a /tmp/boulangerie/. /home/container/
rm -rf /tmp/boulangerie
else
echo "Mise à jour du dépôt Git..."
git fetch origin
git reset --hard origin/main
fi
echo "Git : $(git rev-parse --short HEAD)"
# --------------------------------------
# Backend
# --------------------------------------
cd /home/container/backend
python3 manage.py check
echo "Démarrage Django sur :1029"
python3 manage.py migrate --noinput
python3 manage.py runserver 0.0.0.0:1029 &
BACKEND_PID=$!
# --------------------------------------
# Frontend
# --------------------------------------
cd /home/container/frontend
if [ ! -x "node_modules/.bin/vite" ]; then
echo "node_modules absent → installation npm..."
npm ci
fi
export VITE_API_URL="/api"
echo "Build React..."
npm run build
echo "Démarrage frontend sur :1028"
npm run preview -- --host 0.0.0.0 --port 1028 &
FRONTEND_PID=$!
# --------------------------------------
# Arrêt propre
# --------------------------------------
cleanup() {
echo "Arrêt des applications..."
kill "$BACKEND_PID" 2>/dev/null || true
kill "$FRONTEND_PID" 2>/dev/null || true
wait "$BACKEND_PID" 2>/dev/null || true
wait "$FRONTEND_PID" 2>/dev/null || true
}
trap cleanup SIGTERM SIGINT EXIT
echo "======================================"
echo " Frontend : :1028"
echo " Backend : :1029"
echo "======================================"
wait -n "$BACKEND_PID" "$FRONTEND_PID"