Skip to content

Commit

Permalink
feat: optimize image size with multi-staged dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun-Kolanu committed Oct 23, 2024
1 parent 10fab1c commit 6f3fef9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# Development Docker file
FROM node:18-alpine

# Stage 1: Dependency fetching step
FROM node:18-alpine AS deps

WORKDIR /async

# Install development dependencies
# Install dependencies
COPY package.json package-lock.json ./
RUN npm install

# Copy the rest of the application files
# Stage 2: Development environment
FROM node:18-alpine AS dev

WORKDIR /async

# Copy only node_modules from dependency stage by avoiding temporary caches formed
COPY --from=deps /async/node_modules ./node_modules

COPY . .

# Expose the port for development (if needed)
EXPOSE 3000

# Set environment variables for development (optional)
# Set environment variables for development
ENV NODE_ENV=development

CMD ["npm", "run", "dev"]

0 comments on commit 6f3fef9

Please sign in to comment.