Skip to content

Commit

Permalink
Merge pull request #836 from unsync/feature/betterdocker
Browse files Browse the repository at this point in the history
feature/reduce docker image size using build stage
  • Loading branch information
VisargD authored Dec 26, 2024
2 parents f429049 + 2296940 commit 3a176ac
Showing 1 changed file with 14 additions and 3 deletions.
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"]

0 comments on commit 3a176ac

Please sign in to comment.