2021-05-08 16:52:33 -04:00
|
|
|
FROM rust:latest
|
|
|
|
ENV CARGO_HOME=/deps
|
2021-05-13 21:21:06 -04:00
|
|
|
ARG APP_NAME=rpn_rs
|
2021-05-08 16:52:33 -04:00
|
|
|
WORKDIR /work
|
|
|
|
|
|
|
|
deps:
|
|
|
|
COPY ./Cargo.toml ./Cargo.lock .
|
2021-05-13 21:21:06 -04:00
|
|
|
# This is a binary program, expose a main.rs file
|
2021-05-08 16:52:33 -04:00
|
|
|
RUN mkdir src && touch src/main.rs
|
|
|
|
RUN cargo fetch
|
|
|
|
SAVE ARTIFACT /deps
|
|
|
|
|
2021-05-13 21:21:06 -04:00
|
|
|
rust-builder:
|
|
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
|
|
|
RUN rustup target add x86_64-pc-windows-gnu
|
|
|
|
RUN rustup target add i686-unknown-linux-musl
|
|
|
|
RUN rustup target add aarch64-unknown-linux-musl
|
|
|
|
RUN rustup target add arm-unknown-linux-musleabi
|
|
|
|
RUN rustup target add armv7-unknown-linux-musleabi
|
|
|
|
|
|
|
|
RUN apt-get update
|
|
|
|
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu gdb-mingw-w64 gcc-mingw-w64-x86-64
|
|
|
|
|
|
|
|
SAVE IMAGE docker-wg:5000/rust-builder
|
|
|
|
|
2021-05-08 16:52:33 -04:00
|
|
|
build:
|
2021-05-13 21:21:06 -04:00
|
|
|
FROM +rust-builder
|
|
|
|
COPY . .
|
|
|
|
COPY +deps/deps /deps
|
|
|
|
|
2021-05-08 16:52:33 -04:00
|
|
|
ARG TOOLCHAIN
|
|
|
|
|
2021-05-12 23:32:37 -04:00
|
|
|
RUN cargo build --release --target "$TOOLCHAIN"
|
2021-05-14 23:23:38 -04:00
|
|
|
ARG EXT
|
2021-05-13 21:21:06 -04:00
|
|
|
ARG STRIP_CMD
|
2021-05-14 23:23:38 -04:00
|
|
|
RUN if [ "$STRIP_CMD" ]; then "$STRIP_CMD" "target/$TOOLCHAIN/release/$APP_NAME$EXT"; fi
|
|
|
|
# --force for windows since multiple hardlinks
|
|
|
|
RUN xz --force --keep "target/$TOOLCHAIN/release/$APP_NAME$EXT"
|
|
|
|
SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME$EXT AS LOCAL target/$TOOLCHAIN/release/$APP_NAME-$TOOLCHAIN$EXT
|
|
|
|
SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME$EXT.xz AS LOCAL target/$TOOLCHAIN/release/$APP_NAME-$TOOLCHAIN$EXT.xz
|
2021-05-08 16:52:33 -04:00
|
|
|
|
|
|
|
all:
|
2021-05-13 21:21:06 -04:00
|
|
|
BUILD --build-arg TOOLCHAIN=x86_64-unknown-linux-musl --build-arg STRIP_CMD=x86_64-linux-gnu-strip +build
|
|
|
|
BUILD --build-arg TOOLCHAIN=i686-unknown-linux-musl --build-arg STRIP_CMD=x86_64-linux-gnu-strip +build
|
|
|
|
BUILD --build-arg TOOLCHAIN=aarch64-unknown-linux-musl --build-arg STRIP_CMD=aarch64-linux-gnu-strip +build
|
|
|
|
BUILD --build-arg TOOLCHAIN=arm-unknown-linux-musleabi --build-arg STRIP_CMD=arm-linux-gnueabi-strip +build
|
|
|
|
BUILD --build-arg TOOLCHAIN=armv7-unknown-linux-musleabi --build-arg STRIP_CMD=arm-linux-gnueabi-strip +build
|
2021-05-14 23:23:38 -04:00
|
|
|
BUILD --build-arg TOOLCHAIN=x86_64-pc-windows-gnu --build-arg STRIP_CMD= --build-arg EXT=.exe +build
|