Why? Literally everything in this article would apply to online books as well, except "type it in" would be "copy and paste"
With a physical book, code requires extra pages, which drive up the cost, and make the book take up more space (though this can be a positive if your book might look too short otherwise). With a digital book, you can freely include as much code as you want.
How about distributing the "full" book as a docker image where you have both the source and compiled binaries (if relevant) of all the code samples in the book?