miroslavpejic85 / mirotalksfu

🏆 WebRTC - SFU - Simple, Secure, Scalable Real-Time Video Conferences Up to 8k, compatible with all browsers and platforms.
https://sfu.mirotalk.com
GNU Affero General Public License v3.0
2.15k stars 340 forks source link

Reduce docker image size #120

Closed rogerdz closed 1 year ago

rogerdz commented 1 year ago

Reduce docker image size from 781MB to 411MB image image

I tested and found no errors

miroslavpejic85 commented 1 year ago

Wow, you're right. The lines you provided in the Dockerfile can help reduce the size of the final Docker image. Let's write some note what's happening here:

  1. npm cache clean --force: This command clears the npm package cache. The npm package cache can accumulate over time as you install various packages. Cleaning the cache helps to remove unnecessary files, which can save space in the final image.

  2. rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/* /usr/share/doc/*: This command removes various temporary and cache files from the system. Let's break down each part:

    • /tmp/*: Deletes files from the system's temporary directory. Temporary files can take up space, and removing them is a common practice to keep the image size smaller.
    • /var/lib/apt/lists/*: Deletes package lists retrieved during the package installation process. These lists can take up space and are not necessary in the final image.
    • /var/tmp/*: Removes temporary files from another temporary directory.
    • /usr/share/doc/*: Deletes documentation files for installed packages. While documentation is useful, it's often not required in the final image, especially for production use cases.

By including these commands in your Dockerfile, you're effectively cleaning up various temporary and unnecessary files, which helps in reducing the size of the final Docker image. This can be particularly important in production environments where smaller image sizes contribute to faster deployment times and reduced resource consumption.

Thank you so much for this fantastic PR!

PS: I'm currently enjoying my vacation, but I'll everything merge asap! 😊