Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed changes #2

Closed
7 tasks done
rucoder opened this issue Aug 17, 2024 · 12 comments
Closed
7 tasks done

Proposed changes #2

rucoder opened this issue Aug 17, 2024 · 12 comments
Assignees

Comments

@rucoder
Copy link
Contributor

rucoder commented Aug 17, 2024

  • Base on alpine 3.20. It has better support for RISC-V, besides we are moving to 3.20 anyways
    UPDATE: I can confirm 3.20 works. You can use 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/Dockerfile
  • Freeze cargo-chef and cargo-sbom version , it can be done as following cargo install [email protected]
  • 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 CI
  • it seems to use true cross-compilation for downstream applications we should use
FROM --platform=$BUILDPLATFORM lf-edge/eve-rust:1.80.1 AS toolchain
  • and add .cargo/config.toml
  • Make a note, that riscv64 is not supported as host platform and cross compilation is not possible. Besides, std lib is not available on riscv rust so we cannot compile applications for this architecture
  • Make a note that build.yml must have network: true
@deitch
Copy link
Contributor

deitch commented Aug 18, 2024

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

@deitch
Copy link
Contributor

deitch commented Aug 18, 2024

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
Copy link
Contributor

deitch commented Aug 18, 2024

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
Copy link
Contributor

deitch commented Aug 18, 2024

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
Copy link
Contributor

deitch commented Aug 18, 2024

and add .cargo/config.toml

Do you mind opening a PR for it?

@deitch
Copy link
Contributor

deitch commented Aug 18, 2024

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 [email protected] [email protected]

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
Copy link
Contributor

deitch commented Aug 18, 2024

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

@rucoder
Copy link
Contributor Author

rucoder commented Aug 18, 2024

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
Copy link
Contributor

deitch commented Aug 18, 2024

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
Copy link
Contributor Author

rucoder commented Aug 18, 2024

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
Copy link
Contributor Author

rucoder commented Aug 19, 2024

we can close this one

@deitch
Copy link
Contributor

deitch commented Aug 19, 2024

Hooray!

@deitch deitch closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants