How to Reduce Node.js Docker Image Size?
I had a web application which is written in Node.js and I wanted to dockerize it. So went to the Node.js official site and found Dockerizing a Node.js web app article. I created the Dockerfile as it says in the article. Then I built the docker image with docker build, the created image size was 1.09GB Dockerfile which produce 1.09GB docker image FROM node:18 # Create app directory WORKDIR /usr/src/app # Install app dependencies # A wildcard is used to ensure both package.json AND package-lock.json are copied # where available (npm@5+) COPY package*.json ./ RUN npm install # If you are building your code for production # RUN npm ci --omit=dev # Bundle app source COPY . . EXPOSE 8080 CMD [ "node", "server.js" ] Bigger images requires disk space and downloading them takes longer time. 1GB size was too big for me and i thought it could be reduced and investigated. ...