Remove obsolete changelog, guides, specs and TODO files
This commit is contained in:
@@ -1,49 +1,158 @@
|
||||
#!/bin/bash
|
||||
# Build multi-platform ObsiGate Docker image
|
||||
# =============================================================================
|
||||
# ObsiGate — Script de build et déploiement Docker
|
||||
# =============================================================================
|
||||
#
|
||||
# Usage :
|
||||
# ./build.sh [OPTIONS]
|
||||
#
|
||||
# Options :
|
||||
# --help, -h Affiche cette aide
|
||||
# --build-only Construit l'image sans démarrer le conteneur
|
||||
# --no-cache Rebuild complet sans cache Docker (défaut)
|
||||
# --cache Utilise le cache Docker (plus rapide si peu de changements)
|
||||
# --progress=plain Sortie verbeuse (défaut: auto)
|
||||
# --progress=tty Sortie interactive (barres de progression)
|
||||
#
|
||||
# Étapes exécutées :
|
||||
# 1. Vérifie que Docker et Docker Compose sont installés
|
||||
# 2. Valide le fichier docker-compose.yml
|
||||
# 3. Vérifie que les volumes montés existent sur le host
|
||||
# 4. Construit l'image Docker (multi-stage, ~180MB)
|
||||
# 5. Démarre le conteneur en arrière-plan
|
||||
# 6. Affiche le statut et les logs
|
||||
#
|
||||
# Exemples :
|
||||
# ./build.sh # Build from scratch + démarrage
|
||||
# ./build.sh --cache # Build avec cache + démarrage
|
||||
# ./build.sh --build-only # Build uniquement, sans démarrer
|
||||
# ./build.sh --progress=plain # Sortie verbeuse
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
# ----- Configuration -----
|
||||
VERSION="1.1.0"
|
||||
IMAGE_NAME="obsigate"
|
||||
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7,linux/386"
|
||||
BUILDER_NAME="obsigate-builder"
|
||||
|
||||
# ----- Helpers -----
|
||||
info() { printf '\033[1;34m[INFO]\033[0m %s\n' "$*"; }
|
||||
ok() { printf '\033[1;32m[OK]\033[0m %s\n' "$*"; }
|
||||
warn() { printf '\033[1;33m[WARN]\033[0m %s\n' "$*"; }
|
||||
error() { printf '\033[1;31m[ERR]\033[0m %s\n' "$*" >&2; }
|
||||
|
||||
# ----- Usage -----
|
||||
show_help() {
|
||||
awk '/^# =/{c++; if(c>=3)exit; next} c>=2{print}' "$0" | sed 's/^# //'
|
||||
exit 0
|
||||
}
|
||||
|
||||
# ----- Parse args -----
|
||||
BUILD_ONLY=false
|
||||
USE_CACHE=false
|
||||
BUILD_ARGS=()
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--help|-h)
|
||||
show_help
|
||||
;;
|
||||
--build-only)
|
||||
BUILD_ONLY=true
|
||||
;;
|
||||
--no-cache)
|
||||
USE_CACHE=false
|
||||
;;
|
||||
--cache)
|
||||
USE_CACHE=true
|
||||
;;
|
||||
*)
|
||||
BUILD_ARGS+=("$arg")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ----- Pre-flight checks -----
|
||||
if ! command -v docker &>/dev/null; then
|
||||
error "docker introuvable. Installez Docker avant de continuer."
|
||||
error "Docker est introuvable. Installez Docker avant de continuer."
|
||||
exit 1
|
||||
fi
|
||||
ok "Docker $(docker --version | grep -oP '\d+\.\d+\.\d+') détecté"
|
||||
|
||||
COMPOSE_CMD=""
|
||||
if docker compose version &>/dev/null 2>&1; then
|
||||
COMPOSE_CMD="docker compose"
|
||||
elif docker-compose version &>/dev/null 2>&1; then
|
||||
COMPOSE_CMD="docker-compose"
|
||||
warn "Utilisation de docker-compose (legacy). Pensez à installer le plugin docker compose."
|
||||
else
|
||||
error "Docker Compose est introuvable. Installez-le : https://docs.docker.com/compose/install/"
|
||||
exit 1
|
||||
fi
|
||||
ok "$($COMPOSE_CMD version --short 2>/dev/null || $COMPOSE_CMD version | head -1)"
|
||||
|
||||
# ----- Validate compose file -----
|
||||
COMPOSE_FILE="docker-compose.yml"
|
||||
if [[ ! -f "$COMPOSE_FILE" ]]; then
|
||||
error "$COMPOSE_FILE introuvable dans $(pwd)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker buildx version &>/dev/null; then
|
||||
error "docker buildx introuvable. Mettez à jour Docker ou installez le plugin buildx."
|
||||
exit 1
|
||||
info "=== ObsiGate — Build & Deploy ==="
|
||||
info "Fichier compose : $COMPOSE_FILE"
|
||||
|
||||
# ----- Extract volume mount paths from compose file and warn about missing ones -----
|
||||
info "Vérification des volumes montés sur le host..."
|
||||
VOLUME_COUNT=0
|
||||
MISSING_COUNT=0
|
||||
while IFS= read -r line; do
|
||||
# Lines like: - /host/path:/container/path
|
||||
if [[ "$line" =~ ^[[:space:]]*-[[:space:]]+(/[^:]+): ]]; then
|
||||
host_path="${BASH_REMATCH[1]}"
|
||||
VOLUME_COUNT=$((VOLUME_COUNT + 1))
|
||||
if [[ ! -d "$host_path" && ! -f "$host_path" ]]; then
|
||||
warn "Volume source absent : $host_path (le conteneur créera un dossier vide)"
|
||||
MISSING_COUNT=$((MISSING_COUNT + 1))
|
||||
else
|
||||
ok "Volume trouvé : $host_path"
|
||||
fi
|
||||
fi
|
||||
done < <(grep -E '^\s+-\s+/' "$COMPOSE_FILE")
|
||||
|
||||
if [[ "$VOLUME_COUNT" -eq 0 ]]; then
|
||||
warn "Aucun volume host détecté dans $COMPOSE_FILE. Pensez à configurer vos vaults."
|
||||
fi
|
||||
if [[ "$MISSING_COUNT" -gt 0 ]]; then
|
||||
warn "$MISSING_COUNT volume(s) absent(s). Vérifiez vos chemins dans $COMPOSE_FILE."
|
||||
fi
|
||||
|
||||
info "=== ObsiGate v${VERSION} — Multi-Platform Build ==="
|
||||
info "Platforms : ${PLATFORMS}"
|
||||
|
||||
# ----- Builder setup -----
|
||||
docker buildx create --use --name "${BUILDER_NAME}" 2>/dev/null || true
|
||||
|
||||
# ----- Build -----
|
||||
# Note: --load only works for single platform; use --push for multi-platform registry push.
|
||||
# For local testing, build one platform at a time (see below).
|
||||
|
||||
docker buildx build \
|
||||
--platform "${PLATFORMS}" \
|
||||
--tag "${IMAGE_NAME}:latest" \
|
||||
--tag "${IMAGE_NAME}:${VERSION}" \
|
||||
"$@" \
|
||||
.
|
||||
|
||||
ok "Build terminé (v${VERSION})."
|
||||
echo ""
|
||||
info "Pour un push vers un registry : $0 --push"
|
||||
info "Pour un test local (amd64) :"
|
||||
echo " docker buildx build --platform linux/amd64 --load -t ${IMAGE_NAME}:latest ."
|
||||
echo " docker-compose up -d"
|
||||
|
||||
# ----- Build the image -----
|
||||
BUILD_FLAGS=()
|
||||
if [[ "$USE_CACHE" == false ]]; then
|
||||
BUILD_FLAGS+=(--no-cache)
|
||||
info "Construction de l'image Docker (sans cache)..."
|
||||
else
|
||||
info "Construction de l'image Docker (avec cache)..."
|
||||
fi
|
||||
|
||||
$COMPOSE_CMD build "${BUILD_FLAGS[@]}" "${BUILD_ARGS[@]}"
|
||||
ok "Image construite avec succès"
|
||||
|
||||
# ----- Stop if build-only -----
|
||||
if [[ "$BUILD_ONLY" == true ]]; then
|
||||
echo ""
|
||||
info "Mode build-only : conteneur non démarré."
|
||||
info "Pour démarrer manuellement : $COMPOSE_CMD up -d"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ----- Start the container -----
|
||||
info "Démarrage du conteneur..."
|
||||
$COMPOSE_CMD up -d --remove-orphans
|
||||
ok "Conteneur démarré"
|
||||
|
||||
# ----- Show status -----
|
||||
echo ""
|
||||
info "Statut du conteneur :"
|
||||
$COMPOSE_CMD ps
|
||||
|
||||
echo ""
|
||||
info "Logs récents (Ctrl+C pour quitter) :"
|
||||
$COMPOSE_CMD logs --tail=20 -f
|
||||
|
||||
Reference in New Issue
Block a user