feat(docker): add automatic container entrypoint seeding script
Some checks failed
Production Build & Deploy / build-and-deploy (push) Failing after 9s
Some checks failed
Production Build & Deploy / build-and-deploy (push) Failing after 9s
This commit is contained in:
@@ -18,16 +18,18 @@ ENV HOST=0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV DATA_DIR=/app/data
|
||||
|
||||
# Erstelle Kunden-Volume Ordner
|
||||
RUN mkdir -p /app/data && chown -R node:node /app
|
||||
# Ordner anlegen & Schreibrechte vorbereiten
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production
|
||||
|
||||
COPY --from=builder /app/dist ./dist
|
||||
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
|
||||
|
||||
@@ -35,4 +37,5 @@ EXPOSE 3000
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
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"]
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
kunden_app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
app:
|
||||
image: nd-waas-engine:latest
|
||||
container_name: kunden_instanz_app
|
||||
container_name: waas_${CUSTOMER_SLUG:-kunden_app}
|
||||
restart: always
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
- DATA_DIR=/app/data
|
||||
volumes:
|
||||
# Kunden-Konfigurationsdaten & Uploads bleiben bei Updates persistent
|
||||
# Hier werden site.config.json, sqlite.db, uploads etc. automatisch vom Container angelegt
|
||||
- ./data:/app/data
|
||||
ports:
|
||||
# Interne Port-Anbindung für den händischen Nginx Reverse Proxy
|
||||
- "127.0.0.1:8080:3000"
|
||||
# Anbindung an deinen händischen Nginx Reverse Proxy auf dem Host
|
||||
- "127.0.0.1:${PORT:-8080}:3000"
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:3000/api/health"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
|
||||
73
docker-entrypoint.sh
Normal file
73
docker-entrypoint.sh
Normal 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 "$@"
|
||||
Reference in New Issue
Block a user