A Node.js Docker image based on node:alpine with package managers (npm, yarn, and corepack) removed, reducing image size by 7.2%.
- Node.js Version: 25.1.0
- Base Image: alpine:3.22
- Size: 50.6MB
- Docker Hub: utsavladani/node
- Tags:
latest - GitHub: Utsav-Ladani/node-image
While there are many Node.js Docker images available, this image is specifically designed for production deployments where:
- Smaller size is crucial for faster deployments and reduced attack surface
- Package managers are not needed in production
For applications that don't require package managers or build steps:
FROM utsavladani/node:latest
WORKDIR /app
# Copy application code
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]For applications requiring npm packages and build process:
FROM node:25.1.0-alpine3.22 AS base
# ---------------------------------
# Stage: Build
FROM base AS builder
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build
# ---------------------------------
# Stage: Production Dependencies
FROM base AS production-dependencies
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
# ---------------------------------
# Stage: Runtime
FROM utsavladani/node:latest
WORKDIR /app
COPY --from=builder /app/dist ./
COPY --from=production-dependencies /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "index.js"]# Build the image
docker build -t my-app:latest .
# Run the image
docker run -it --rm -p 3000:3000 --name my-app my-app:latestThis project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Utsav Ladani