-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize image size with multi-staged dockerfile
- Loading branch information
1 parent
983c80e
commit 79c67ea
Showing
1 changed file
with
13 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |