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

feature/reduce docker image size using build stage #836

Open
wants to merge 1 commit into
base: main
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
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the official Node.js runtime as a parent image
FROM node:20-alpine
FROM node:20-alpine AS build

# Set the working directory in the container
WORKDIR /app
Expand All @@ -16,10 +16,21 @@ COPY . .
# Build the application and clean up
RUN npm run build \
&& rm -rf node_modules \
&& npm install --production
&& npm install --omit=dev

# Use the official Node.js runtime as a parent image
FROM node:20-alpine

# Set the working directory in the container
WORKDIR /app

# Copy the build directory, node_modules, and package.json to the working directory
COPY --from=build /app/build /app/build
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/package.json /app/package.json

# Expose port 8787
EXPOSE 8787

ENTRYPOINT ["npm"]
CMD ["run", "start:node"]
CMD ["run", "start:node"]
Loading