Deploying Racket Web Apps With Docker
Since there was a question about deploying Racket code using Docker on the Racket Reddit this morning, I figured I’d write a quick follow-up to my post about Deploying Racket Web Apps. My preference is still to avoid using Docker and just use the method described in that post by default. But, if I have to use Docker for some reason, then I’ll typically use a two-stage build to build a distribution in the first stage and then copy that distribution into the second stage in order to get a minimal Docker image that I can easily ship around.
Given the following app, saved as
I would write the following
When this image gets built, the
build stage creates a distribution
of the app that gets copied into the
final stage. At the end, the
build stage is discarded and the end result is a roughly 150MB Docker
image with just my code in it and a minimal Debian system. Not quite
as minimal as you can get out of using a similar method with Go, but
Racket distributions have a high baseline, so a real app wouldn’t be
much bigger than this.