Files
websitedev/deploy.sh
T
Do Siki 35bf43798d
CI — Test & Build / 🧪 Run Tests & Generate Reports (push) Waiting to run
CI — Test & Build / 🏗️ Build Docker Image (push) Blocked by required conditions
feat(deploy): add staging environment with dedicated docker compose
- Add docker-compose.staging.yml (app on 127.0.0.1:8081, separate MongoDB
  on 127.0.0.1:27019, dedicated volume/network)
- deploy.sh: select compose file and port per environment
  (staging 8081, production 8080)
- Dockerfile: accept NEXT_PUBLIC_SITE_URL as build arg (inlined at build
  time for NEXT_PUBLIC_ vars); pass it in both compose files
- Add .env.staging.example and .env.production.example
2026-08-17 13:07:51 +02:00

59 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# mozdIT Deploy Script — natív docker compose, Dokploy nélkül
# Használat: ./deploy.sh [staging|production]
# A szerveren fut (git pull + rebuild + indítás).
# Compose fájl és port env-enként különbözik.
set -euo pipefail
ENV="$1"
if [ "$ENV" != "staging" ] && [ "$ENV" != "production" ]; then
echo "Hiba: Hiányzó vagy érvénytelen környezet paraméter."
echo "Használat: ./deploy.sh staging VAGY ./deploy.sh production"
exit 1
fi
# WHY: staging és production külön compose fájlt és portot használ, hogy
# ugyanazon a szerveren ne ütközzenek (prod 8080, staging 8081).
COMPOSE_FILE="docker-compose.${ENV}.yml"
DEFAULT_PORT=8080
if [ "$ENV" = "staging" ]; then
DEFAULT_PORT=8081
fi
echo "🚀 Deploy indítása: [$ENV] környezet (${COMPOSE_FILE})"
# 1. Kód frissítése
echo "📦 Kód frissítése a main ágról..."
git pull origin main
# 2. Környezeti változók (.env.<env>)
ENV_FILE=".env.${ENV}"
if [ ! -f "$ENV_FILE" ]; then
echo "❌ Hiba: $ENV_FILE fájl nem található."
echo " Másold le a .env.staging.example / .env.production.example fájlt $ENV_FILE néven, és töltsd ki."
exit 1
fi
echo "🔑 Környezeti változók betöltése ($ENV_FILE)..."
# 3. Docker konténerek újraépítése és indítása
echo "🐳 Build és indítás..."
docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up --build -d
# 4. Healthcheck
echo "⏳ Healthcheck (max 60s)..."
HEALTH_URL="http://localhost:${APP_PORT:-$DEFAULT_PORT}/api/health"
for i in $(seq 1 30); do
if curl -sf "$HEALTH_URL" > /dev/null 2>&1; then
echo "✅ Healthcheck OK: $HEALTH_URL"
echo "✅ Deploy sikeres: [$ENV]"
exit 0
fi
sleep 2
done
echo "❌ Healthcheck sikertelen: $HEALTH_URL"
docker compose -f "$COMPOSE_FILE" logs app --tail 50
exit 1