← Zurück zu Team für Go-Desktop-Apps
Entdecke, wie der Skill hilft
Container-Laufzeit konfigurieren
Macht Containerstart und -ende durch Konfigurationsprüfung, Prozesssignale und klare Laufzeitgrenzen vorhersehbar.
containers-runtime-config
Teammitglieder mit diesem Skill
Wann ist der Skill hilfreich?
Nutze dies, wenn Container beim Start scheitern, Stoppsignale ignorieren oder je Umgebung anders laufen.
Wobei hilft er dir?
- Erstellt eine minimale Laufzeit mit unprivilegiertem Nutzer und fixierten Eingaben.
- Validiert Pflichtkonfiguration vor dem Öffnen von Listenern ohne Geheimnisausgabe.
- Verbindet Signalbehandlung, Bereitschaft und strukturierte Logs mit Wiederherstellung.
Das könntest du fragen
Untersuche einen beim Stoppen hängenden Container, der vor seiner Datenbankbereitschaft startet. Verzögere den Datenbankstart und sende während einer Anfrage ein Beendigungssignal. Bereitschaft gilt erst bei Nutzbarkeit; das Herunterfahren hält die Frist ein.
Ausführliche Dokumentation
Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.
Weniger anzeigen
Containers & Runtime Configuration
Build containers that are small, deterministic, unprivileged, and responsive to operating-system lifecycle signals (SIGTERM), with explicit startup validation for all runtime configuration.
Production Multi-Stage Dockerfile Checklist
# Stage 1: Build with pinned base image and cached dependency layer
FROM node:22.14.0-bookworm-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY tsconfig.json ./
COPY src ./src
RUN npm run build && npm prune --omit=dev
# Stage 2: Minimal, non-root production runtime
FROM node:22.14.0-bookworm-slim AS runtime
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build --chown=node:node /app/package.json ./
COPY --from=build --chown=node:node /app/node_modules ./node_modules
COPY --from=build --chown=node:node /app/dist ./dist
USER node
EXPOSE 3000
# Exec form (JSON array) so the runtime process is PID 1 (or under tini/dumb-init) and receives SIGTERM!
CMD ["node", "dist/index.js"]
Five Non-Negotiable Container Rules
- Exec form
CMD/ENTRYPOINT& PID 1 Signal Handling:- Never use shell form
CMD npm startorCMD node server.js. Shell form spawns/bin/sh -cas PID 1, which swallowsSIGTERMon container stop, causing every deployment to hang until the 10–30 secondSIGKILLtimeout and dropping in-flight requests! - Invoke the binary directly in exec form (
CMD ["node", "dist/index.js"]) or wrap with--init/tinisoSIGTERMtriggers your application's graceful shutdown handler (server.close(), DB pool drain).
- Never use shell form
- Run as a non-root user:
- Always switch to an unprivileged user (
USER node,USER nonroot, or a dedicated UID/GID10001) beforeCMD, and keep the root filesystem read-only where possible with explicit writable mounts (/tmpor volume paths).
- Always switch to an unprivileged user (
- Fail-fast runtime configuration validation:
- Validate all required environment variables (
PORT,DATABASE_URL,REDIS_URL, feature flags) at process startup using a strict schema before opening network listeners. Print every missing or invalid key name in one diagnostic error rather than crashing 20 minutes later on a code path.
- Validate all required environment variables (
- Local parity with
docker-compose:- Use
healthcheck:+depends_on: { db: { condition: service_healthy } }indocker-compose.ymlso application containers wait for Postgres/Redis/migrations to accept connections cleanly instead of crash-looping on cold start.
- Use
- Log to
stdout/stderr:- Never write application logs Exclusively to unrotated files inside an ephemeral container filesystem; emit structured logs to
stdout/stderrand configure log rotation (max-size,max-file) on the container runtime.
- Never write application logs Exclusively to unrotated files inside an ephemeral container filesystem; emit structured logs to
Enthaltene Dateien 1
SKILL.md
