diff --git a/setup-pod.sh b/setup-pod.sh index 51bb738..d648a4a 100755 --- a/setup-pod.sh +++ b/setup-pod.sh @@ -3,11 +3,8 @@ # Konfiguration POD_NAME="symfony-dev" PROJECT_DIR="$(pwd)" -DB_PASSWORD="devpassword" # Γ„ndere dies! -DB_NAME="symfony_db" -DB_USER="symfony_user" -DB_HOST="localhost" -DB_PORT="5432" +REDIS_HOST="localhost" +REDIS_PORT="6379" ENV_FILE="$PROJECT_DIR/.env" @@ -15,18 +12,18 @@ echo "πŸš€ Starte Symfony Pod Setup..." # 1. .env Datei automatisch erstellen/aktualisieren echo "πŸ“ Konfiguriere .env Datei..." -DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?serverVersion=16&charset=utf8" +REDIS_URL="redis://${REDIS_HOST}:${REDIS_PORT}" if [ -f "$ENV_FILE" ]; then - # Datei existiert - DATABASE_URL aktualisieren oder hinzufΓΌgen - if grep -q "^DATABASE_URL=" "$ENV_FILE"; then - sed -i "s|^DATABASE_URL=.*|DATABASE_URL=\"$DATABASE_URL\"|" "$ENV_FILE" - echo " βœ… DATABASE_URL aktualisiert" + # Datei existiert - REDIS_URL aktualisieren oder hinzufΓΌgen + if grep -q "^REDIS_URL=" "$ENV_FILE"; then + sed -i "s|^REDIS_URL=.*|REDIS_URL=\"$REDIS_URL\"|" "$ENV_FILE" + echo " βœ… REDIS_URL aktualisiert" else - echo "DATABASE_URL=\"$DATABASE_URL\"" >> "$ENV_FILE" - echo " βœ… DATABASE_URL hinzugefΓΌgt" + echo "REDIS_URL=\"$REDIS_URL\"" >> "$ENV_FILE" + echo " βœ… REDIS_URL hinzugefΓΌgt" fi - + # APP_ENV sicherstellen if ! grep -q "^APP_ENV=" "$ENV_FILE"; then echo "APP_ENV=dev" >> "$ENV_FILE" @@ -38,7 +35,7 @@ else ### symfony-pod environment ### APP_ENV=dev APP_SECRET=$(openssl rand -hex 16) -DATABASE_URL="$DATABASE_URL" +REDIS_URL="$REDIS_URL" ### symfony-pod environment ### EOF echo " βœ… .env Datei erstellt" @@ -51,7 +48,7 @@ podman pod create --name $POD_NAME -p 8080:80 # 3. PHP-FPM Container bauen und starten echo "🐘 Baue und starte PHP-FPM..." podman build -t symfony-php -f podman/php/Containerfile . -podman run -d \ +podman run --replace -d \ --pod $POD_NAME \ --name symfony-php \ -v $PROJECT_DIR:/var/www/html:Z \ @@ -61,36 +58,31 @@ podman run -d \ # 4. Nginx Container bauen und starten echo "🌐 Baue und starte Nginx..." podman build -t symfony-nginx -f podman/nginx/Containerfile . -podman run -d \ +podman run --replace -d \ --pod $POD_NAME \ --name symfony-nginx \ symfony-nginx -# 5. PostgreSQL Container starten -echo "🐘 Starte PostgreSQL..." -podman run -d \ +# 5. Redis Container starten +echo "πŸ”΄ Starte Redis..." +podman run --replace -d \ --pod $POD_NAME \ - --name symfony-db \ - -e POSTGRES_DB=$DB_NAME \ - -e POSTGRES_USER=$DB_USER \ - -e POSTGRES_PASSWORD=$DB_PASSWORD \ - -v symfony-db-data:/var/lib/postgresql/data \ - docker.io/library/postgres:16-alpine + --name symfony-redis \ + -v symfony-redis-data:/data \ + docker.io/library/redis:8-alpine \ + redis-server --appendonly yes -# 6. Warten auf DB Start -echo "⏳ Warte auf Datenbank-Start..." -sleep 5 +# 6. Warten auf Redis Start +echo "⏳ Warte auf Redis-Start..." +sleep 3 # 7. Symfony AbhΓ€ngigkeiten installieren (falls composer.json existiert) if [ -f "$PROJECT_DIR/composer.json" ]; then echo "πŸ“¦ Installiere Composer AbhΓ€ngigkeiten..." podman exec -it symfony-php composer install - - echo "πŸ—„οΈ Erstelle Datenbank..." - podman exec -it symfony-php php bin/console doctrine:database:create --if-not-exists - - echo "πŸ”„ FΓΌhre Migrationen aus..." - podman exec -it symfony-php php bin/console doctrine:migrations:migrate --no-interaction + + echo "🧹 Leere Symfony Cache..." + podman exec -it symfony-php php bin/console cache:clear else echo "ℹ️ Keine composer.json gefunden - ΓΌberspringe Installation" fi @@ -99,12 +91,10 @@ echo "" echo "βœ… Setup abgeschlossen!" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "🌍 Deine App ist erreichbar unter: http://localhost:8080" -echo "πŸ”‘ DB Zugangsdaten:" -echo " Host: $DB_HOST (innerhalb des Pods)" -echo " Port: $DB_PORT" -echo " User: $DB_USER" -echo " Pass: $DB_PASSWORD" -echo " DB: $DB_NAME" +echo "πŸ”΄ Redis Zugangsdaten:" +echo " Host: $REDIS_HOST (innerhalb des Pods)" +echo " Port: $REDIS_PORT" +echo " URL: $REDIS_URL" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "πŸ“ .env Datei wurde automatisch konfiguriert" echo "" \ No newline at end of file