Open
Description
Checklist
- I've looked through the issues and pull requests for similar request
- This feature could be solved with a custom docker image (optional)
Describe your request
We should provide a good story for doing something like
FROM magic_cross as cross
COPY . .
RUN cross build --release --target aarch64-unknown-linux-gnu
FROM ubuntu:20.04
COPY --from=cross ./target/release/binary .
CMD ["./binary"]
Describe why this would be a good inclusion for cross
This would make it easy to setup a dockerfile with the needed binary.
Today, this can be solved with
FROM ubuntu:20.04
COPY ./target/aarch64-unknown-linux-gnu/release/binary ./
CMD ["./binary"]
$ cross build --target aarch64-unknown-linux-gnu
Compiling binary v0.1.0 (/binary)
Finished release [optimized] target(s) in 11.68s
$ docker build .
[+] Building 3.0s (7/7) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 144B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:20.04 0.5s
=> [internal] load build context 0.1s
=> => transferring context: 4.32MB 0.1s
=> [1/2] FROM docker.io/library/ubuntu:20.04@sha256:0e0402cd13f68137edb0266e1d2c682f217814420f2d43d300ed8f65479b14fb 2.3s
=> => resolve docker.io/library/ubuntu:20.04@sha256:0e0402cd13f68137edb0266e1d2c682f217814420f2d43d300ed8f65479b14fb 0.0s
=> => sha256:0e0402cd13f68137edb0266e1d2c682f217814420f2d43d300ed8f65479b14fb 1.42kB / 1.42kB 0.0s
=> => sha256:bfd9523988a26a8913fbced7d00b00805572d093c4d8cbc64252b45e032302d5 529B / 529B 0.0s
=> => sha256:43ed104e759f96978d95473568dbaef829695dbade5c10be56f344948ab0caa1 1.48kB / 1.48kB 0.0s
=> => sha256:f04b4bbe15805316c8fda79beedd3b77e6b1ffcd0acf81226c3089e63f6bffeb 27.19MB / 27.19MB 1.3s
=> => extracting sha256:f04b4bbe15805316c8fda79beedd3b77e6b1ffcd0acf81226c3089e63f6bffeb 0.8s
=> [2/2] COPY ./target/aarch64-unknown-linux-gnu/release/binary ./ 0.1s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:d45f5b6b5a01fbe01b3fe6d18a9b124c1586c0905ed92012bf3eb65dd18ae2b1