There are some drawbacks and performance considerations when using this approach, it can be simpler but way slower for big projects.
This article can be considered a part 2 of Running rust on ARM32v7K3S Oracle cluster so we will not be creating the rust project and all that here, but focusing on building and running the project.
Let’s jump to the example
The new Dockerfile
You will notice that this Dockerfile
is way simpler than the ones from the previous article, since it runs natively
as ARM32v7, the main difference is the base image being
arm32v7/rust:1.63.0, this can be further extended for more
architectures, see this article for
Last steps for QEMU/Docker
After installing the required packages you will still need to perform some simple steps in order for it to work with docker and buildah, the first command is needed for docker to be able to use the required QEMU emulation and the second is just to validate that everything works fine
Short names error
If you get an error about short names when pulling images add the following line to your
Lets build it
For the build we will use buildah because it is smarter than docker for this kind of scenarios.
Lets test it
After building it, we can push it to the docker daemon and then run it and test it from another terminal
Notice: you will see some warnings about the architecture, that’s fine as we are emulating things.
This project build with the rust toolchain and then copied to an ARM32v7 image took 2 minutes, but using QEMU and the given emulation it took around 8 minutes and a half, so it is something to be aware since the difference is quite big.
You can see it running here, a very basic HTML Curriculum vitae.
For more details and to see how everything fits together I encourage you to clone the repo, test it, and modify it to make your own.
The source for this article is here
If you spot any error or have any suggestion, please send me a message so it gets fixed.