• Shaarli
  • Tag cloud
  • Picture wall
  • Daily
  • RSS
  • Login
4251 shaares
Filters

How I Reduced Docker Image Size from 1.43 GB to 22.4 MB | by Mohammad Faisal | JavaScript In Plain English | Medium

QRCode

Step 4. Multistage Build

In our previous configurations, we were copying all of our source codes into the working directory.
But it’s unnecessary as we only need the build folder to serve our website. So now we will use the concept of multi-stage build to cut down the unnecessary code and dependencies from our final image.
The configuration will look something like this.


# STAGE 1

FROM node:12-alpine AS build
WORKDIR /app
COPY package.json ./
RUN yarn  install
COPY . /app
RUN yarn build

# STAGE 2
FROM node:12-alpine
WORKDIR /app
RUN npm install -g webserver.local
COPY --from=build /app/build ./build
EXPOSE 3000
CMD webserver.local -d ./build
https://medium.com/javascript-in-plain-english/how-i-reduced-docker-image-size-from-1-43-gb-to-22-4-mb-84058d70574b
January 13, 2021 at 3:18:16 PM EST *
docker
FILLER
Shaarli · The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community · Documentation
Fold Fold all Expand Expand all Are you sure you want to delete this link? Are you sure you want to delete this tag? The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community