@fin_ger that's almost what I've been trying to do yesterday.
I'm using rustlang/rust:nightly as a build container and then copy the compiled binary into a alpine container but of course it doesn't run because it's not compiled properly.
I don't know how to configure the build properly and I couldn't find docs yesterday - probably because I don't know what I should search for :D "static linking" is something I'll look into now, thanks!
@kevin You have to use the alpine container for compiling. E.g. `apk add cargo` and then get your project into the alpine container and compile inside alpine. When you are statically linking you can just copy the binary to a scratch container and it will work. You can check whether statically linking succeeded with ldd. The Dockerfile would roughly look like this:
RUN apk update && apk add rust cargo
RUN cargo build --release --target x86_64-alpine-linux-musl
COPY --from=0 /project/target/x86_64-alpine-linux-musl/release/your-binary .
ENTRYPOINT [ "/your-binary" ]
@fin_ger thanks! That's exactly what I was looking for. I somehow didn't think about "just" installing rust and cargo in an alpine container :D
@kevin Thank the alpine team for providing rust tools in their awesome distro! Without the alpine team musl support for rust would be light years away ;) And with this statically linking for rust...
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!