2025-12-26 08:45:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2026-01-01 14:02:38 +01:00
|
|
|
echo "🚀 Starting Bamort Production Environment..."
|
2025-12-26 08:45:47 +01:00
|
|
|
|
|
|
|
|
# Prüfe ob Docker läuft
|
|
|
|
|
if ! docker info > /dev/null 2>&1; then
|
|
|
|
|
echo "❌ Docker ist nicht gestartet. Bitte starte Docker zuerst."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Gehe ins Docker-Verzeichnis
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
2026-02-27 11:55:30 +01:00
|
|
|
# Load production environment variables
|
2026-05-02 00:56:11 +02:00
|
|
|
if [ -f .env ]; then
|
|
|
|
|
echo "📝 Loading configuration from .env"
|
|
|
|
|
export $(grep -v '^#' .env | xargs)
|
|
|
|
|
if [ -f .env.local ]; then
|
|
|
|
|
echo "📝 Loading configuration from .env.local"
|
|
|
|
|
export $(grep -v '^#' .env.local | xargs)
|
2026-02-27 11:55:30 +01:00
|
|
|
else
|
2026-05-02 00:56:11 +02:00
|
|
|
echo "⚠️ Warning: .env.local not found, using defaults"
|
2026-02-27 11:55:30 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2026-05-01 18:15:31 +02:00
|
|
|
# Determine image tag from git commit hash (first 5 chars)
|
|
|
|
|
GIT_TAG=$(git -C "$(dirname "$0")/.." rev-parse --short=5 HEAD 2>/dev/null || echo "latest")
|
|
|
|
|
export GIT_TAG
|
|
|
|
|
echo "🏷️ Image tag: ${GIT_TAG}"
|
|
|
|
|
|
2026-01-01 14:02:38 +01:00
|
|
|
echo "📦 Building and starting production containers..."
|
2026-02-27 11:55:30 +01:00
|
|
|
echo "🔧 Frontend will use API: ${API_URL:-https://bamort-api.trokan.de}"
|
|
|
|
|
|
2026-05-01 22:35:18 +02:00
|
|
|
cp ../docker/frontend-entrypoint.sh ../frontend/docker-entrypoint.sh
|
|
|
|
|
|
2026-05-01 18:15:31 +02:00
|
|
|
# Build only if images for this commit don't exist yet
|
2026-05-02 00:56:11 +02:00
|
|
|
ENV_FILES="--env-file .env"
|
|
|
|
|
if [ -f .env.local ]; then
|
|
|
|
|
ENV_FILES="$ENV_FILES --env-file .env.local"
|
|
|
|
|
echo "📝 Applying overrides from .env.local"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-05-01 18:15:31 +02:00
|
|
|
if ! docker image inspect "bamort-backend:${GIT_TAG}" > /dev/null 2>&1 || \
|
|
|
|
|
! docker image inspect "bamort-frontend:${GIT_TAG}" > /dev/null 2>&1; then
|
|
|
|
|
echo "🔨 Images not found for tag '${GIT_TAG}', building..."
|
2026-05-02 00:56:11 +02:00
|
|
|
docker-compose -f docker-compose.yml $ENV_FILES -p bamort build
|
2026-05-01 18:15:31 +02:00
|
|
|
else
|
|
|
|
|
echo "✅ Images already exist for tag '${GIT_TAG}', skipping build."
|
|
|
|
|
fi
|
2025-12-26 08:45:47 +01:00
|
|
|
|
|
|
|
|
# Stoppe vorhandene Container
|
2026-05-01 18:15:31 +02:00
|
|
|
docker-compose -f docker-compose.yml -p bamort down
|
2025-12-26 08:45:47 +01:00
|
|
|
|
|
|
|
|
# Baue und starte die Container
|
2026-05-02 00:56:11 +02:00
|
|
|
docker-compose -f docker-compose.yml $ENV_FILES -p bamort up -d
|
2025-12-26 08:45:47 +01:00
|
|
|
|
2026-02-27 11:55:30 +01:00
|
|
|
echo "✅ Production environment started."
|
|
|
|
|
echo "📱 Frontend: http://localhost:8181"
|
|
|
|
|
echo "🔌 Backend: http://localhost:8182"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "💡 To change API URL: Edit .env.prd and run:"
|
2026-05-01 18:15:31 +02:00
|
|
|
echo " docker-compose -f docker-compose.yml -p bamort restart frontend"
|
2026-02-27 11:55:30 +01:00
|
|
|
echo " (No rebuild needed!)"
|