Deno with Docker
I've been following deno from a far for a while now, I'm particularly interested in it for two reasons.
- First class typescript support - I hate having to compile things with babel or webpack and then having to run them via node in production it always ends-up being a little brittle & complicated with everyone having their own home grown scripts and workflows for dev and production.
If you want to skip the rest and just check out the code it can be found 👉 here
The first thing to figure out was how to create a reproducible build, turned out to be fairly easy you can create a lock file with:
deno cache --lock=lock.json --lock-write src/deps.ts
And then install with that lock file using:
deno cache --reload --lock=lock.json src/deps.ts
The next was how to make that build as small as possible, I did this by using deno's compile feature which can cross-compile standalone binaries (quite similar to vercel's pkg). The linux executable is dynamically linked with
glibc so you'll that present, luckily most systems have this. I unfortunately encountered the issue because I tried to use the vanilla apline image.
make size_uncompressed- this will give you the ondisk size of the image.
The on disk size comes out a 53.3mb (30mb of this is your executable) the rest is the apline image. (Node apline image is 116MB)
make size_compressed- This will give you the gzipped image size which should be comparable to what you'd pull from a registry.
The compressed size comes in at 21mb, the node.js apline image by comparison is 38.93 MB
make run- run the server.
Next I'm looking forward to try out their built in test framework too see how that fairs against more established things like jest.