docker-containerization

Creates multi-stage Dockerfiles and Docker Compose configurations for full-stack JavaScript applications.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill docker-containerization-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-containerization
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/docker-containerization
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill docker-containerization-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Containerizing a full-stack JavaScript application involves many error-prone decisions: image size optimization, non-root security, layer caching, service orchestration, and health checks. This Skill provides production-grade Dockerfile and docker-compose.yml templates for Node.js/Express backends, React/Vite frontends, and MongoDB so you avoid common misconfigurations. ## Core Features & Use Cases - Multi-Stage Backend Dockerfile: Builds a TypeScript Node.js/Express image under 150MB with dependency caching, npm ci, pruned production node_modules, non-root USER node execution, and an HTTP health check. - React Vite Frontend Image: Compiles static assets in a build stage and serves them via nginx:alpine-slim with SPA fallback routing (try_files ... /index.html). - Full-Stack Compose Orchestration: Spins up MongoDB 7 with authentication, persistent volumes, health-gated startup ordering (condition: service_healthy), and environment variable injection for JWT secrets and CORS. - Use Case: You have an Express + React + MongoDB chat app and need to ship it. Use this Skill to generate both Dockerfiles and a compose file, then run the entire stack locally with one docker compose up. ## Quick Start Generate a production multi-stage Dockerfile for my Express TypeScript backend and a docker-compose.yml that runs it alongside MongoDB and my React frontend.

Frequently Asked Questions about docker-containerization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Dockerfile for a Node.js Express backend?

Use a multi-stage build: one stage installs dependencies with npm ci, a second compiles TypeScript and prunes dev dependencies, and a final runner stage copies only dist and production node_modules. Run as the non-root node user and expose a /health endpoint for Docker health checks.

How to dockerize a React Vite frontend with Nginx?

Build the static assets in a node:22-alpine stage with npm run build, then copy the dist output into an nginx:alpine-slim image. Add an Nginx config with try_files $uri $uri/ /index.html so client-side React Router paths resolve correctly.

How do I reduce Docker image size for Node.js apps?

Use multi-stage builds so only compiled output and pruned production node_modules reach the final image, choose alpine or distroless base images, and add a .dockerignore excluding node_modules, dist, .git, and .env. This typically brings Express images under 150MB.

How do I make Docker Compose wait for MongoDB to be ready?

Define a healthcheck on the MongoDB service using mongosh --eval db.adminCommand('ping'), then set depends_on with condition: service_healthy on the backend service. Compose will delay backend startup until MongoDB passes its health check.

Why should Node.js containers not run as root?

Running as root means a process that escapes the application could gain root access to the container and potentially the host. The official Node images include a node user, so adding USER node to the Dockerfile enforces least-privilege execution in production.

Should I use npm install or npm ci in Docker builds?

Use npm ci in Docker builds because it installs exactly what the lockfile specifies, fails on lockfile mismatches, and produces reproducible images. npm install can silently update dependencies, breaking build determinism.