utsavladani/node

By utsavladani

Updated 2 months ago

The Node.js docker image without package managers

Image
Languages & frameworks
0

331

utsavladani/node repository overview

Node.js Docker Image

A Node.js Docker image based on node:alpine with package managers (npm, yarn, and corepack) removed, reducing image size by 6.25%.

Docker Pulls Docker Image Size License

Image Details

Why Use This 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 and no need to worry about npm vulnerabilities.

How to Use This Image

Simple Application (No Build Step)

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"]
Complex Application (With Build Step)

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"]
Building and Running
# 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

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by Utsav Ladani

Tag summary

Content type

Image

Digest

sha256:e15c998d2

Size

53.1 MB

Last updated

2 months ago

docker pull utsavladani/node