Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : UQO Éval — Le Grand Défi Immobilier8# File : scripts/deploy.sh9# Module : scripts10# Repository : https://git.spboucher.ai/uqo-eval-jeux11# Project Website : https://jeux.uqo-eval.app12# Created : 2026-11-2513# Last Modified : 2026-11-2514#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041#42# UQO ÉVAL — Le Grand Défi Immobilier · déploiement sur la grappe MacLustr.43#44# Deux situations, deux chemins (voir docs/DEPLOYMENT.md) :45#46# 1. Création ou réinstallation complète (depuis le poste de l'opérateur) :47# scripts/deploy.sh creation48# Copie ce dossier vers le staging de la passerelle, puis laisse `mld`49# synchroniser le nœud, installer les dépendances, migrer la base,50# compiler l'interface, démarrer PM2 et poser la route publique.51#52# 2. Mise à jour courante (SUR LE NŒUD, dans le dépôt déployé — règle53# « remote-first » de la grappe) :54# scripts/deploy.sh local55# Installe les dépendances, applique les migrations, recompile56# l'interface, redémarre le serveur et vérifie la santé.57#58# Retour arrière : `git checkout <commit précédent>` sur le nœud, puis59# `scripts/deploy.sh local`. Les migrations sont additives ; en cas de besoin,60# restaurer la sauvegarde de la veille avec scripts/restore.sh.6162set -euo pipefail6364APP="uqo-eval-jeux"65ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"66MLD="${MLD:-$HOME/Desktop/cluster-skill/mld}"67export PATH="/opt/homebrew/opt/postgresql@17/bin:/opt/homebrew/bin:$PATH"6869case "${1:-}" in70 creation)71 [ -x "$MLD" ] || { echo "ERREUR : wrapper mld introuvable ($MLD)" >&2; exit 2; }72 "$MLD" stage "$ROOT_DIR" "$APP"73 "$MLD" deploy "$APP"74 ;;75 local)76 cd "$ROOT_DIR"77 [ -f .env ] || { echo "ERREUR : .env absent (secrets) — voir docs/DEPLOYMENT.md" >&2; exit 2; }78 npm ci --no-audit --no-fund --silent79 node --env-file=.env --disable-warning=ExperimentalWarning apps/api/src/cli.ts migrate80 npm run build --silent81 pm2 restart "$APP" --update-env82 sleep 383 PORT="$(grep -E "^PORT=" .env | cut -d= -f2)" scripts/healthcheck.sh84 ;;85 *)86 echo "Usage : scripts/deploy.sh creation | local" >&287 exit 288 ;;89esac90