Size matters. When you’re shipping code in containers, it’s important to remember that your container images are pulled on every node within your Swarm or Kubernetes clusters. This means that as you scale out your cluster nodes or schedule workloads on new nodes in your cluster, the size of your image becomes non-trivial for cold start time.
It’s a best practice to use containers to resolve dependencies (dotnet restore, npm install) and build (dotnet build, webpack) code because it ensures a consistent environment where the team’s specific version of Node.js becomes less important. Unfortunately, this also requires that the containers in which we build code must also have build dependencies installed, such as the .NET Core SDK or Node.js. Since you don’t need all those dependencies in production, how can you slim down your images?