Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimize image size with multi-staged dockerfile #3313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading