Skip to content

Commit

Permalink
Implemented multistage building in the Dockerfile to reduce file size
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmyt committed May 18, 2024
1 parent 10d382d commit 374dfd8
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,7 +1,5 @@
FROM node:20-alpine
RUN apk add g++ make cmake python3 --no-cache

ENV NODE_ENV=production
FROM node:20-alpine AS build
RUN apk add g++ make cmake python3

WORKDIR /myspeed

Expand All @@ -13,7 +11,17 @@ RUN npm install
RUN cd client && npm install --force
RUN npm run build
RUN mv /myspeed/client/build /myspeed
RUN rm -rf /myspeed/client

FROM node:20-alpine

ENV NODE_ENV=production

WORKDIR /myspeed

COPY --from=build /myspeed/build /myspeed/build
COPY --from=build /myspeed/server /myspeed/server
COPY --from=build /myspeed/node_modules /myspeed/node_modules
COPY --from=build /myspeed/package.json /myspeed/package.json

VOLUME ["/myspeed/data"]

Expand Down

0 comments on commit 374dfd8

Please sign in to comment.