Closed rucoder closed 2 months ago
Took care of freezing versions, and bumping to alpine:3.20
Make a note, that riscv64 is not supported as host platform
Done
and cross compilation is not possible
Well, it is. You can compile to riscv64 with glibc, but that does not really help us.
Make a note that build.yml must have network: true
No need. This image is not being built using linuxkit pkg build
. It is entirely via plain old docker build
.
Add either makefile or shell script
If we need anything, then let's add a Makefile rather than some custom script.
But do we need anything? We are using the docker-build-push
action to build and (optionally) push it. What more do we need?
and add .cargo/config.toml
Do you mind opening a PR for it?
it seems to use true cross-compilation we should use
I wasn't sure about that. We are building these images to actually run under those platforms. E.g. we are building eve-rust:1.8.1
for arm64, expected to run on arm64, then we need the installed rustc/cargo/etc. to be native arm64. It is one thing when you just are using them in a build stage, and it is the final output you are looking for. It is different if you actually want the rustc/cargo/etc. to be the TARGETPLATFORM.
We might be able to do a multistage, something like:
ARG RUST_VERSION=1.80.1
FROM rust:${RUST_VERSION}-alpine3.20 as toolchain
ENV TARGETS="x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu riscv64gc-unknown-linux-gnu"
RUN rustup target add ${TARGETS}
# needed for cargo-chef and cargo-sbom, as well as many other compilations
RUN apk add musl-dev linux-headers make
FROM --platform=$BUILDPLATFORM rust:1.80.1-alpine3.20 as builder
RUN apk add musl-dev linux-headers make
RUN cargo install cargo-chef@0.1.67 cargo-sbom@0.9.1
FROM toolchain
COPY --from=builder /usr/local/cargo/bin/cargo-chef /usr/local/cargo/bin
COPY --from=builder /usr/local/cargo/bin/cargo-sbom /usr/local/cargo/bin
That probably is faster, we can try it. For this one, I will open a PR.
@rucoder I opened #3 to address the cross-compilation. Unfortunately, it fails. Maybe you can figure it out?
Make a note that build.yml must have network: true
No need. This image is not being built using
linuxkit pkg build
. It is entirely via plain olddocker build
.
Oh, I meant examples for building rust application in eve
Oh, I meant examples for building rust application in eve
We cannot. Those downstream application builds need to be with network: no
. Because of reproducibility and SBoM issues. Hence the vendoring. Which we can discuss separately.
Oh, I meant examples for building rust application in eve
We cannot. Those downstream application builds need to be with
network: no
. Because of reproducibility and SBoM issues. Hence the vendoring. Which we can discuss separately.
Ok, but examples must be updated to support cross compilation. I'll submit a pr
we can close this one
Hooray!
mikemzed/eve-rust:1.80.1-alpine-3.20
for testing UPDATE 2 no riscv support yet https://github.com/rust-lang/docker-rust/blob/3b6565cd3b0b7c9cb084f07461cb959f7cf77c16/1.80.1/alpine3.20/Dockerfilecargo install cargo-chef@v0.1.67
Add either makefile or shell script to build and push the image so we do not need to remember the command line. Maybe useful for testing before CIBesides, std lib is not available on riscv rust so we cannot compile applications for this architectureMake a note thatbuild.yml
must havenetwork: true