|
||
---|---|---|
.woodpecker | ||
public | ||
src | ||
.gitignore | ||
Dockerfile | ||
package-lock.json | ||
package.json | ||
README.md |
Pour la version en français, c'est ici: 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:
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:
npm install
Then run the following command to build the docker image:
docker build -t 'react-simple' .
You can inspect your images and verify the size yourself with the following command:
docker image ls
I use Nushell and rigrep to filter only on the image in question using the following command:
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:
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 :
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:
npm install
Puis en lançant la commande suivante pour builder l'image:
docker build -t 'react-simple' .
Vous pouvez inspecter la taille de votre image avec la commande suivante:
docker image ls
J'utilise personnellement Nushell et rigrep pour ne filtrer que sur l'image en question:
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: