#!/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!)"