Hey guys, I made a thing! I call it
RoaaR, you can see it here: https://github.com/shaunmulligan/roaar.
Lately I have been playing around and trying to learn the rust language, but it gets really annoying having to include all the rust toolchain and pushing 900MB+ container images to my raspberry pi’s. So I created this little template project I call RoaaR - Rust on an Armv7 ResinOS (amazing, grammatically correct name, I know). What RoaaR does is to allow you to cross compile your rust code in a container locally on your laptop and then spit that compiled binary into a really small container that we end up shipping to either a local resinOS device or a fleet of resin.io managed devices. This also has the added benefit of only pushing your compiled binary to the end devices, just in case you are worried about people stealing your super sweet sauce code
Currently RoaaR can do two different things at the compile stage, 1.) it will cross-compile your rust src in an x86 container, this works great if you are writing pure rust code and don’t need to link to any of those pesky unsafe C libraries using the FFI.
If you are one of the unlucky ones, like myself who needs to link against something like
libspotify so I can use the rustify crate, then you can pass the
--unsafe option to the
build.sh and your code will get built in an QEMU emulated container on your laptop. This allows you can install some stuff, like
libspotify so your code is built and linked properly and you dont have to worry too much about sys_roots and that kinda jazz.
Currently RoaaR is still pretty rough (as most Friday Hacks are) but it does end up producing some pretty minimal rust based containers. My super simple starting example produces an image which is 21.53MB on disk. We can definitely make it smaller if we use
FROM scratch, but I prefer having a bit of a file system and a few utilities, so I usually opt for a small Alpine linux base.
Is anyone else building Rust based stuff?