Pour la version en français, c'est ici: [Français](#français) # English ## How to reduce the size of your docker 🐳 images 💿? We're starting from a basic React application générated with a simple Dockerfile with disastrous conséquences: ```Dockerfile FROM node:18 COPY . . RUN npm install EXPOSE 3000 CMD ["npm", "start"] ``` For your information, the image weight a whopping 2.03GB 🤯 !!!!! A mountain 🏔️ of data for a simple web application that is empty at the moment!!! You can test it yourself by first running the following command: ```shell npm install ``` Then run the following command to build the docker image: ```shell docker build -t 'react-simple' . ``` You can inspect your images and verify the size yourself with the following command: ```shell docker image ls ``` I use Nushell and rigrep to filter only on the image in question using the following command: ```shell docker image ls | from ssv | where repository starts-with 'react' ``` Here's the result of running this command that shows how shamefully big the image is: ![Size of the image](./assets/react-simple-size.png) # Français ## Comment réduire la taille de vos images 💿 docker 🐳 ? On part d'une application React tout juste généré et avec un Dockerfile simple mais avec de grosses conséquences : ```Dockerfile FROM node:18 COPY . . RUN npm install EXPOSE 3000 CMD ["npm", "start"] ``` Pour indication, l'image qui en résulte pèse environ 2.03GB 🤯 !!!!! Une montagne 🏔️ de données pour une simple application web vide pour l'instant !!! Vous pouvez le testez vous même en lançant d'abord la commande suivante: ```shell npm install ``` Puis en lançant la commande suivante pour builder l'image: ```shell docker build -t 'react-simple' . ``` Vous pouvez inspecter la taille de votre image avec la commande suivante: ```shell docker image ls ``` J'utilise personnellement Nushell et rigrep pour ne filtrer que sur l'image en question: ```shell docker image ls | from ssv | where repository starts-with 'react' ``` Voici un aperçu de ce que cette commande m'affiche avec le poids de l'image assez désastreux: ![Taille de cette image](./assets/react-simple-size.png)