feat(docker): add automatic container entrypoint seeding script
Some checks failed
Production Build & Deploy / build-and-deploy (push) Failing after 9s

This commit is contained in:
Daniel S
2026-08-09 22:05:48 +02:00
parent b021f9aaa7
commit 64c257f050
3 changed files with 89 additions and 11 deletions

View File

@@ -18,16 +18,18 @@ ENV HOST=0.0.0.0
ENV PORT=3000 ENV PORT=3000
ENV DATA_DIR=/app/data ENV DATA_DIR=/app/data
# Erstelle Kunden-Volume Ordner # Ordner anlegen & Schreibrechte vorbereiten
RUN mkdir -p /app/data && chown -R node:node /app RUN mkdir -p /app/data
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
COPY --from=builder /app/dist ./dist COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
USER node # Ausführungsrechte für das Entrypoint-Skript setzen
RUN chmod +x /app/docker-entrypoint.sh
EXPOSE 3000 EXPOSE 3000
@@ -35,4 +37,5 @@ EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1 CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["node", "./dist/server/entry.mjs"] CMD ["node", "./dist/server/entry.mjs"]

View File

@@ -1,23 +1,25 @@
version: '3.8' version: '3.8'
services: services:
kunden_app: app:
build:
context: .
dockerfile: Dockerfile
image: nd-waas-engine:latest image: nd-waas-engine:latest
container_name: kunden_instanz_app container_name: waas_${CUSTOMER_SLUG:-kunden_app}
restart: always restart: always
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- PORT=3000 - PORT=3000
- DATA_DIR=/app/data - DATA_DIR=/app/data
volumes: volumes:
# Kunden-Konfigurationsdaten & Uploads bleiben bei Updates persistent # Hier werden site.config.json, sqlite.db, uploads etc. automatisch vom Container angelegt
- ./data:/app/data - ./data:/app/data
ports: ports:
# Interne Port-Anbindung für den händischen Nginx Reverse Proxy # Anbindung an deinen händischen Nginx Reverse Proxy auf dem Host
- "127.0.0.1:8080:3000" - "127.0.0.1:${PORT:-8080}:3000"
healthcheck:
test: ["CMD", "wget", "--spider", "http://localhost:3000/api/health"]
interval: 10s
timeout: 3s
retries: 3
logging: logging:
driver: "json-file" driver: "json-file"
options: options:

73
docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,73 @@
#!/bin/sh
set -e
DATA_DIR=${DATA_DIR:-/app/data}
echo "🚀 [WaaS Container Entrypoint] Prüfe Daten-Volume unter ${DATA_DIR}..."
# 1. Sicherstellen, dass das Volume-Verzeichnis existiert
mkdir -p "$DATA_DIR"
# 2. site.config.json Seeding
if [ ! -f "$DATA_DIR/site.config.json" ]; then
echo "📄 Keine site.config.json gefunden. Erstelle Standard-Konfiguration..."
cat <<EOF > "$DATA_DIR/site.config.json"
{
"site_info": {
"title": "N&D IT Solutions Kunden-Website",
"company_name": "Mein Unternehmen",
"homepage_id": "page_home_01"
},
"navigation": [
{ "label": "Startseite", "page_id": "page_home_01" }
],
"pages": [
{
"id": "page_home_01",
"slug": "/",
"title": "Startseite",
"is_published": true,
"sections": [
{
"id": "sec_hero_init",
"type": "HeroSection",
"settings": {
"title": "Herzlich Willkommen",
"subtitle": "Ihre neue Website ist erfolgreich gestartet."
}
}
]
}
]
}
EOF
fi
# 3. theme.config.json Seeding
if [ ! -f "$DATA_DIR/theme.config.json" ]; then
echo "🎨 Keine theme.config.json gefunden. Erstelle Standard-Theme..."
cat <<EOF > "$DATA_DIR/theme.config.json"
{
"presetKey": "corporate-dark",
"mode": "dark"
}
EOF
fi
# 4. smtp.config.json Seeding
if [ ! -f "$DATA_DIR/smtp.config.json" ]; then
echo "✉️ Keine smtp.config.json gefunden. Erstelle Standard-SMTP Config..."
cat <<EOF > "$DATA_DIR/smtp.config.json"
{
"host": "localhost",
"port": 1025,
"from": "noreply@kunden-domain.de",
"recipient": "info@kunden-domain.de"
}
EOF
fi
echo "✅ All-in-One Initialisierung abgeschlossen. Starte Astro SSR Node Server..."
# Führe den eigentlichen Befehl aus (CMD aus Dockerfile)
exec "$@"