Manual deployments are where bugs and late nights come from. Containerizing your Node.js app and adding a CI/CD pipeline makes every release repeatable. Here is a practical checklist we use on production projects.
1. A small, production-ready Dockerfile
Use a multi-stage build so your final image contains only what the app needs to run:
FROM node:22-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY . .
USER node
EXPOSE 3000
CMD ["node", "server.js"]- Add a
.dockerignore(node_modules, .git, .env, logs) to keep images small. - Run as the non-root
nodeuser. - Never bake secrets into the image — pass them as environment variables at runtime.
2. Docker Compose for local development
Compose runs your API with its database and cache (for example MongoDB or PostgreSQL and Redis) using one command, so every developer gets the same environment.
3. A CI pipeline on every push
- Install dependencies with
npm ci. - Run linting and tests.
- Build the Docker image and tag it with the commit SHA.
- Push the image to a registry (GitHub Container Registry, Docker Hub or AWS ECR).
4. Safe deployments
- Separate staging and production so changes are verified before customers see them.
- Health checks. Expose a
/healthendpoint so the platform only routes traffic to healthy containers. - Zero-downtime releases. Start the new version, check health, then switch traffic.
- Easy rollback. Because images are tagged by commit, rolling back means redeploying the previous tag.
5. Production hardening
- API rate limiting and caching to protect and speed up your service.
- Centralised logs and basic uptime monitoring with alerts.
- HTTPS everywhere, with certificates renewed automatically.
- Automated database backups — and a tested restore process.
Where to host
Front ends and Next.js apps deploy well to Vercel or Netlify. APIs and workers fit AWS, DigitalOcean or any container platform. The pipeline above works with all of them.
Want this set up for your project? Our DevOps and cloud deployment service covers Docker, CI/CD and hosting, and pairs well with API and backend development.



