Skip to content

Utsav-Ladani/node-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

The Node.js docker image without package managers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors