agentleFS
manishdashsharmamanishdashsharma/express-backend-skills/skills/deploy-docker/SKILL.md

deploy-docker

Skill0 starsChanged 15 days agoMITView on GitHub

Production packaging for Node.js Express backends — multi-stage Dockerfile (non-root, tini, healthcheck), entrypoint that runs Prisma migrations, docker-compose for local Postgres/Mongo/Redis, scheduler container with supercronic, health/readiness endpoints, graceful shutdown and an environment checklist. Use when preparing a backend to deploy, containerizing it, or debugging production startup.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep only the services the project uses.

    line 83
  2. Very specific:

    All required env vars set.

    line 97

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Deploy with Docker

Dockerfile

FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
COPY prisma ./prisma
RUN npm ci --omit=dev --ignore-scripts && npm run db:generate

FROM node:22-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
RUN apk add --no-cache tini supercronic && addgroup -S app && adduser -S app -G app
COPY --from=deps /app/node_modules ./node_modules
COPY package.json package-lock.json ./
COPY prisma ./prisma
COPY src ./src
COPY cron ./cron
COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh && chown -R app:app /app
USER app
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
  CMD ["node", "src/healthcheck.js"]
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"]
CMD ["node", "src/server.js"]

Mongoose projects drop the prisma lines. Drop supercronic and cron if there are no jobs. Add python3 make g++ to the deps stage only if a native module (bcrypt) needs building.

  • tini as PID 1 forwards SIGTERM so graceful shutdown runs.
  • The health check runs src/healthcheck.js (shipped in the create-backend templates), a tiny file that requests /v1/health and exits 0 or 1. Keep probes as files in the image, not inline code.
  • Non-root user. No .env baked into the image; add a .dockerignore with node_modules, .env*, logs, .git, coverage.

Entrypoint (Prisma)

#!/bin/sh
set -e
if [ "${RUN_MIGRATIONS:-true}" = "true" ]; then
  ./node_modules/.bin/prisma migrate deploy
fi
exec "$@"

With several API replicas, set RUN_MIGRATIONS=true on one release task only.

Local services (docker-compose.yml)

services:
  postgres:
    image: postgres:17-alpine
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: YOUR_DB_PASSWORD
      POSTGRES_DB: app
    ports: ['5432:5432']
    volumes: [postgres-data:/var/lib/postgresql/data]
    healthcheck: { test: ['CMD-SHELL', 'pg_isready -U app -d app'], interval: 10s, retries: 5 }
  mongo:
    image: mongo:8
    ports: ['27017:27017']
    volumes: [mongo-data:/data/db]
  redis:
    image: redis:7-alpine
    command: ['redis-server', '--appendonly', 'yes']
    ports: ['6379:6379']
    volumes: [redis-data:/data]
volumes:
  postgres-data:
  mongo-data:
  redis-data:

Keep only the services the project uses. Use pgvector/pgvector:pg17 if you need vector search. Mongo transactions need a replica set (--replSet rs0 + rs.initiate()).

Scheduler

Same image, different command: command: ["supercronic", "/app/cron/prod.crontab"]. Run exactly one scheduler replica (see scheduled-jobs).

Health

  • GET /v1/health — liveness, no dependencies, always fast.
  • GET /v1/health/ready — checks the database (and Redis as informational); 503 when the database is down. Point load balancers at readiness, container healthchecks at liveness.

Production checklist

  • NODE_ENV=production; trust proxy matches the proxy count; CORS origins are the real domains.
  • All required env vars set; secrets differ per environment; AI_KEY_ENCRYPTION_SECRET / JWT secrets are random 32+ bytes.
  • Logs go to stdout as JSON; no secrets in logs.
  • Graceful shutdown: stop accepting, finish in-flight requests, close DB/Redis, force-exit after 30 s.
  • Database: pooled connection limits fit the provider; migrations applied; backups on.
  • Rate limiting enabled; Redis reachable or the app degrades cleanly without it.
  • Behind nginx: proxy_buffering off (or X-Accel-Buffering: no) on SSE routes; request body limit matches Express.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.