The Node.js docker image without package managers
331
A Node.js Docker image based on node:alpine with package managers (npm, yarn, and corepack) removed, reducing image size by 6.25%.
25.6.0alpine:3.2353.1MBlatestWhile there are many Node.js Docker images available, this image is specifically designed for production deployments where:
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:latest
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Utsav Ladani
Content type
Image
Digest
sha256:e15c998d2…
Size
53.1 MB
Last updated
2 months ago
docker pull utsavladani/node