lf-edge / eve-rust

0 stars 1 forks source link

Proposed changes #2

Closed rucoder closed 2 months ago

rucoder commented 2 months ago
deitch commented 2 months ago

Took care of freezing versions, and bumping to alpine:3.20

deitch commented 2 months ago

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.

deitch commented 2 months ago

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.

deitch commented 2 months ago

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?

deitch commented 2 months ago

and add .cargo/config.toml

Do you mind opening a PR for it?

deitch commented 2 months ago

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.

deitch commented 2 months ago

@rucoder I opened #3 to address the cross-compilation. Unfortunately, it fails. Maybe you can figure it out?

rucoder commented 2 months ago

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.

Oh, I meant examples for building rust application in eve

deitch commented 2 months ago

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.

rucoder commented 2 months ago

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

rucoder commented 2 months ago

we can close this one

deitch commented 2 months ago

Hooray!