ramikrispin,
@ramikrispin@mstdn.social avatar

(1/4) 𝐈𝐧𝐭𝐫𝐨𝐝𝐮𝐜𝐭𝐢𝐨𝐧 𝐭𝐨 𝐌𝐮𝐥𝐭𝐢-𝐒𝐭𝐚𝐠𝐞 𝐈𝐦𝐚𝐠𝐞 𝐁𝐮𝐢𝐥𝐝 🐳 𝐟𝐨𝐫 𝐏𝐲𝐭𝐡𝐨𝐧 🐍

The size of the Docker image could quickly increase during the build time. I became more mindful of the image size when I started to deploy on Github Actions. The bigger the image size, the longer the run time and the higher the runtime cost.

This is when you should consider using a multi-stage build 🚀.

🧵👇🏼

#docker #mlops #python #DataScience #medium

ramikrispin,
@ramikrispin@mstdn.social avatar

(2/4) 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐚 𝐦𝐮𝐥𝐭𝐢-𝐬𝐭𝐚𝐠𝐞 𝐛𝐮𝐢𝐥𝐝?
Multi-stage is a build approach that includes the following two steps:
:l1: The first build - installing the required decencies and building the binaries. This image is also called the builder image
:l2: The second build - starting from a new base image and copying from the builder image binaries applications

ramikrispin,
@ramikrispin@mstdn.social avatar

(3/4) 𝐖𝐡𝐞𝐧 𝐬𝐡𝐨𝐮𝐥𝐝 𝐲𝐨𝐮 𝐮𝐬𝐞 𝐚 𝐦𝐮𝐥𝐭𝐢-𝐬𝐭𝐚𝐠𝐞 𝐛𝐮𝐢𝐥𝐝?
You should consider moving your build to a multi-stage build when the build-required dependencies are no longer needed after the build is completed. A classic example is when building a binary application. Also, this is effective when setting up a dockerized Python environment using a virtual environment.

ramikrispin,
@ramikrispin@mstdn.social avatar

(4/4) I created the following tutorial for setting up a dockerized Python environment using a multi-stage approach 👇🏼

https://medium.com/towards-data-science/introduction-to-multi-stage-image-build-for-python-41b94ebe8bb3

Happy Build! 🐳🏗️

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • DreamBathrooms
  • magazineikmin
  • thenastyranch
  • Youngstown
  • slotface
  • everett
  • ngwrru68w68
  • mdbf
  • kavyap
  • tsrsr
  • Durango
  • PowerRangers
  • hgfsjryuu7
  • InstantRegret
  • normalnudes
  • khanakhh
  • osvaldo12
  • vwfavf
  • tacticalgear
  • rosin
  • cubers
  • cisconetworking
  • GTA5RPClips
  • ethstaker
  • tester
  • modclub
  • Leos
  • anitta
  • All magazines