Git Product home page Git Product logo

Comments (4)

Emilgardis avatar Emilgardis commented on June 3, 2024

I'm not sure I understand this feature request, I understand the spirit, but not how it would be used.

Could you explain a bit further how this would be done and used?

I'll also explain abit, today it's possible to do

[target.armv7-unknown-linux-musl.image]
name = "ghcr.io/rust-cross/rust-musl-cross"
toolchain = ["linux/arm/v7=armv7-unknown-linux-musl"]

#1104 exists to track how we would generate multiarch images with the cross-compiled binary inside.

side note, I don't think musl-linux is a valid docker/oci os platform

from cross.

LuckyTurtleDev avatar LuckyTurtleDev commented on June 3, 2024

I should clearyfi this more.
I do want use the docker image, used by cross inside the From step of a Dockerfile for building a rust program.

FROM --platform=$BUILDPLATFORM ghcr.io/rust-cross/rust-musl-cross:aarch64-unknown-linux-musl AS builder
SHELL ["/bin/bash", "-uo", "pipefail", "-c"]

ARG version

RUN apt-get -y update && apt-get -y install protobuf-compiler musl musl-dev musl-tools
ENV PROTOC=/usr/bin/protoc
RUN echo "build version ${version}"
RUN cargo install --locked --git https://github.com/ankitects/anki.git --tag ${version} anki-sync-server
RUN ldd /usr/local/cargo/bin/anki-sync-server


FROM --platform=$BUILDPLATFORM scratch
ENV SYNC_BASE=/data
COPY --from=builder --chmod=0755 /usr/local/cargo/bin/anki-sync-server /
CMD ["./anki-sync-server"]

So I do not use the cross binary, which mean I can not use the meta data section of the cargo.toml.
The problem is that I must change the target in the from step, which make it difficult, to build multi platform image.
Docker does provide the option to use docker Args here. Which are created by buildx.
So you can modifiy the From step like this:

FROM --platform=$BUILDPLATFORM ghcr.io/rust-cross/rust-musl-cross:$TARGETPLATFORM AS builder

The problem is that TARGETPLATFORM platform does not match the name of the rust toolchain. Instead it has values like linux/amd64, linux/arm64, linux/arm/v7. Sadly docker does not allow to use a function here, also variables for previous build steps can not be used, so they is currently no way to map this values to the required toolchain.

My suggestion is to add additional linux/amd64, linux/arm64, linux/arm/v7, etc tags, so TARGETPLATFORM platform can be used directly.

from cross.

Emilgardis avatar Emilgardis commented on June 3, 2024

aha! I think then that you're on the wrong issue tracker, this is cross-rs, for the cross binary that uses it's own docker images and produces binaries on the host system via cross build --target <target>

you probably want to raise this on https://github.com/rust-cross/rust-musl-cross instead! :D

from cross.

LuckyTurtleDev avatar LuckyTurtleDev commented on June 3, 2024

Ups sorry for this.

Issue moved to rust-cross/rust-musl-cross#133

from cross.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.