f62b94af44
Co-authored-by: Copilot <copilot@github.com>
63 lines
2.1 KiB
Bash
Executable File
63 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "🚀 Starting Bamort Production Environment..."
|
|
|
|
# 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")"
|
|
|
|
# Load production environment variables
|
|
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)
|
|
else
|
|
echo "⚠️ Warning: .env.local not found, using defaults"
|
|
fi
|
|
fi
|
|
|
|
# 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}"
|
|
|
|
echo "📦 Building and starting production containers..."
|
|
echo "🔧 Frontend will use API: ${API_URL:-https://bamort-api.trokan.de}"
|
|
|
|
cp ../docker/frontend-entrypoint.sh ../frontend/docker-entrypoint.sh
|
|
|
|
# Build only if images for this commit don't exist yet
|
|
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
|
|
|
|
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..."
|
|
docker-compose -f docker-compose.yml $ENV_FILES -p bamort build
|
|
else
|
|
echo "✅ Images already exist for tag '${GIT_TAG}', skipping build."
|
|
fi
|
|
|
|
# Stoppe vorhandene Container
|
|
docker-compose -f docker-compose.yml -p bamort down
|
|
|
|
# Baue und starte die Container
|
|
docker-compose -f docker-compose.yml $ENV_FILES -p bamort up -d
|
|
|
|
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:"
|
|
echo " docker-compose -f docker-compose.yml -p bamort restart frontend"
|
|
echo " (No rebuild needed!)" |