-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add multiplatform build for anki (#7)
- Loading branch information
1 parent
c6f2961
commit 92a91f1
Showing
7 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
FROM rust AS builder | ||
FROM --platform=$BUILDPLATFORM rust AS builder | ||
SHELL ["/bin/bash", "-uo", "pipefail", "-c"] | ||
|
||
ARG version | ||
ARG TARGETPLATFORM | ||
|
||
ENV TARGET x86_64-unknown-linux-musl | ||
RUN rustup target add "$TARGET" | ||
# add the rust target for the target architecture | ||
RUN if [ "$TARGETPLATFORM" == "linux/amd64" ]; then echo "x86_64-unknown-linux-musl" >/.target; \ | ||
elif [ "$TARGETPLATFORM" == "linux/arm64" ]; then echo "aarch64-unknown-linux-musl" >/.target; \ | ||
elif [ "$TARGETPLATFORM" == "linux/arm/v7" ]; then echo "armv7-unknown-linux-musleabihf" >/.target; \ | ||
else echo "Unknown architecture $TARGETPLATFORM"; exit 1; \ | ||
fi | ||
RUN rustup target add "$(cat /.target)" | ||
|
||
RUN apt-get -y update && apt-get -y install protobuf-compiler musl musl-dev musl-tools | ||
COPY cargo-config.toml $CARGO_HOME/config.toml | ||
RUN echo "$CARGO_HOME/config.toml" | ||
RUN dpkg --add-architecture arm64 | ||
RUN dpkg --add-architecture armhf | ||
# armv7 => armhf | ||
RUN apt-get -y update && apt-get -y install protobuf-compiler clang mold musl musl-dev musl-dev:arm64 musl-dev:armhf musl-tools | ||
ENV PROTOC=/usr/bin/protoc | ||
RUN echo "build version ${version}" | ||
RUN cargo install --locked --target "$TARGET" --git https://github.com/ankitects/anki.git --tag ${version} anki-sync-server | ||
RUN ldd /usr/local/cargo/bin/anki-sync-server | ||
RUN echo "build anki version ${version} for $(cat /.target)" | ||
RUN cargo install --locked --target "$(cat /.target)" --git https://github.com/ankitects/anki.git --tag ${version} anki-sync-server | ||
#RUN ldd /usr/local/cargo/bin/anki-sync-server | ||
|
||
|
||
FROM scratch | ||
FROM --platform=$BUILDPLATFORM scratch | ||
ENV SYNC_BASE=/data | ||
COPY --from=builder --chmod=0755 /usr/local/cargo/bin/anki-sync-server / | ||
CMD ["./anki-sync-server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[env] | ||
CC_armv7-unknown-linux-musleabihf = "clang -I /usr/include/arm-linux-musleabihf -target armv7-unknown-linux-musleabihf -fuse-ld=mold" | ||
CXX_armv7-unknown-linux-musleabihf = "clang++ -I /usr/include/arm-linux-musleabihf -target armv7-unknown-linux-musleabihf -fuse-ld=mold" | ||
CC_aarch64-unknown-linux-musl = "clang -I /usr/include/aarch64-linux-musl -target aarch64-unknown-linux-musl -fuse-ld=mold" | ||
CXX_aarch64-unknown-linux-musl = "clang++ -I /usr/include/aarch64-linux-musl -target aarch64-unknown-linux-musl -fuse-ld=mold" | ||
CC_x86_64-unknown-linux-musl = "clang -I /usr/include/x86_64-linux-musl -target x86_64-unknown-linux-musl -fuse-ld=mold" | ||
CXX_x86_64-unknown-linux-musl = "clang++ -I /usr/include/x86_64-linux-musl -target x86_64-unknown-linux-musl -fuse-ld=mold" | ||
|
||
|
||
[target.x86_64-unknown-linux-musl] | ||
linker = "clang" | ||
rustflags = ["-C", "link-arg=-fuse-ld=mold"] | ||
|
||
[target.aarch64-unknown-linux-musl] | ||
linker = "clang" | ||
rustflags = ["-C", "link-arg=--target=aarch64-unknown-linux-musl", "-C", "link-arg=-fuse-ld=mold"] | ||
|
||
[target.armv7-unknown-linux-musleabihf] | ||
linker = "clang" | ||
rustflags = ["-C", "link-arg=--target=armv7-unknown-linux-musleabihf", "-C", "link-arg=-fuse-ld=mold"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters