fix(setup-ssl): Docker Compose Kompatibilität - unterstützt sowohl docker-compose als auch docker compose

This commit is contained in:
2025-10-01 21:21:39 +02:00
parent 17f1ff698e
commit 18f97e4e5f

View File

@@ -42,6 +42,19 @@ echo -e "${GREEN}✅ Domain: $DOMAIN${NC}"
echo -e "${GREEN}✅ Admin E-Mail: $ADMIN_EMAIL${NC}" echo -e "${GREEN}✅ Admin E-Mail: $ADMIN_EMAIL${NC}"
echo "" echo ""
# Erkenne Docker Compose-Version (docker-compose vs docker compose)
if command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE="docker-compose"
elif docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker compose"
else
echo -e "${RED}❌ Docker Compose nicht gefunden!${NC}"
echo "Bitte installiere Docker Compose"
exit 1
fi
echo -e "${GREEN}✅ Verwende: $DOCKER_COMPOSE${NC}"
# Erstelle nginx.conf mit korrekter Domain # Erstelle nginx.conf mit korrekter Domain
echo -e "${YELLOW}📝 Erstelle Nginx-Konfiguration...${NC}" echo -e "${YELLOW}📝 Erstelle Nginx-Konfiguration...${NC}"
sed "s/\${DOMAIN}/$DOMAIN/g" nginx/nginx.conf > nginx/nginx.conf.tmp sed "s/\${DOMAIN}/$DOMAIN/g" nginx/nginx.conf > nginx/nginx.conf.tmp
@@ -54,7 +67,7 @@ docker volume create certbot-webroot 2>/dev/null || true
# Starte temporären HTTP-Server für Domain-Validierung # Starte temporären HTTP-Server für Domain-Validierung
echo -e "${YELLOW}🌐 Starte temporären HTTP-Server...${NC}" echo -e "${YELLOW}🌐 Starte temporären HTTP-Server...${NC}"
docker compose -f docker compose-prod.yml up -d nginx $DOCKER_COMPOSE -f docker-compose-prod.yml up -d nginx
# Warte bis Nginx läuft # Warte bis Nginx läuft
echo -e "${YELLOW}⏳ Warte auf Nginx...${NC}" echo -e "${YELLOW}⏳ Warte auf Nginx...${NC}"
@@ -62,7 +75,7 @@ sleep 10
# Erstelle SSL-Zertifikat # Erstelle SSL-Zertifikat
echo -e "${YELLOW}🔐 Erstelle SSL-Zertifikat für $DOMAIN...${NC}" echo -e "${YELLOW}🔐 Erstelle SSL-Zertifikat für $DOMAIN...${NC}"
docker compose -f docker compose-prod.yml run --rm certbot certbot certonly \ $DOCKER_COMPOSE -f docker-compose-prod.yml run --rm certbot certbot certonly \
--webroot \ --webroot \
--webroot-path=/var/www/certbot \ --webroot-path=/var/www/certbot \
--email $ADMIN_EMAIL \ --email $ADMIN_EMAIL \
@@ -84,23 +97,23 @@ fi
# Starte alle Services # Starte alle Services
echo -e "${YELLOW}🚀 Starte alle Services...${NC}" echo -e "${YELLOW}🚀 Starte alle Services...${NC}"
docker compose -f docker compose-prod.yml up -d $DOCKER_COMPOSE -f docker-compose-prod.yml up -d
# Prüfe Status # Prüfe Status
echo -e "${YELLOW}🔍 Prüfe Service-Status...${NC}" echo -e "${YELLOW}🔍 Prüfe Service-Status...${NC}"
sleep 5 sleep 5
if docker compose -f docker compose-prod.yml ps | grep -q "Up"; then if $DOCKER_COMPOSE -f docker-compose-prod.yml ps | grep -q "Up"; then
echo -e "${GREEN}✅ Alle Services laufen!${NC}" echo -e "${GREEN}✅ Alle Services laufen!${NC}"
echo "" echo ""
echo -e "${BLUE}🌐 Deine Anwendung ist jetzt verfügbar unter:${NC}" echo -e "${BLUE}🌐 Deine Anwendung ist jetzt verfügbar unter:${NC}"
echo -e "${GREEN} https://$DOMAIN${NC}" echo -e "${GREEN} https://$DOMAIN${NC}"
echo "" echo ""
echo -e "${BLUE}📋 Nützliche Befehle:${NC}" echo -e "${BLUE}📋 Nützliche Befehle:${NC}"
echo " Status anzeigen: docker compose -f docker compose-prod.yml ps" echo " Status anzeigen: $DOCKER_COMPOSE -f docker-compose-prod.yml ps"
echo " Logs anzeigen: docker compose -f docker compose-prod.yml logs -f" echo " Logs anzeigen: $DOCKER_COMPOSE -f docker-compose-prod.yml logs -f"
echo " Services stoppen: docker compose -f docker compose-prod.yml down" echo " Services stoppen: $DOCKER_COMPOSE -f docker-compose-prod.yml down"
echo " Zertifikat erneuern: docker compose -f docker compose-prod.yml run --rm certbot certbot renew" echo " Zertifikat erneuern: $DOCKER_COMPOSE -f docker-compose-prod.yml run --rm certbot certbot renew"
echo "" echo ""
echo -e "${YELLOW}⚠️ Wichtig:${NC}" echo -e "${YELLOW}⚠️ Wichtig:${NC}"
echo " - SSL-Zertifikate werden automatisch alle 12 Stunden erneuert" echo " - SSL-Zertifikate werden automatisch alle 12 Stunden erneuert"
@@ -108,6 +121,6 @@ if docker compose -f docker compose-prod.yml ps | grep -q "Up"; then
echo " - Stelle sicher, dass Port 80 und 443 erreichbar sind" echo " - Stelle sicher, dass Port 80 und 443 erreichbar sind"
else else
echo -e "${RED}❌ Einige Services sind nicht gestartet!${NC}" echo -e "${RED}❌ Einige Services sind nicht gestartet!${NC}"
echo "Prüfe die Logs: docker compose -f docker compose-prod.yml logs" echo "Prüfe die Logs: $DOCKER_COMPOSE -f docker-compose-prod.yml logs"
exit 1 exit 1
fi fi