Enables docker cross compilation to arm64

pull/537/head
Tpt 1 year ago committed by Thomas Tanon
parent 8c68cf4041
commit 03f7641355
  1. 1
      .github/workflows/artifacts.yml
  2. 22
      server/Dockerfile

@ -286,6 +286,7 @@ jobs:
with: with:
context: . context: .
file: server/Dockerfile file: server/Dockerfile
platforms: linux/amd64,linux/arm64
pull: true pull: true
push: true push: true
tags: ${{ steps.docker_meta.outputs.tags }} tags: ${{ steps.docker_meta.outputs.tags }}

@ -1,11 +1,25 @@
FROM rust:1-bullseye as builder FROM --platform=$BUILDPLATFORM rust:1-bullseye as builder
ARG BUILDARCH TARGETARCH
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y libclang-dev clang apt-get install -y libclang-dev clang && \
if [ "$BUILDARCH" != "$TARGETARCH" ] && [ "$TARGETARCH" = "arm64" ] ; \
then \
apt-get install -y g++-aarch64-linux-gnu && \
rustup target add aarch64-unknown-linux-gnu ; \
fi
COPY . /oxigraph COPY . /oxigraph
WORKDIR /oxigraph/server WORKDIR /oxigraph/server
RUN cargo build --release RUN if [ "$BUILDARCH" != "$TARGETARCH" ] && [ "$TARGETARCH" = "arm64" ] ; \
then \
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc && \
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot /usr/aarch64-linux-gnu" && \
cargo build --release --target aarch64-unknown-linux-gnu && \
mv /oxigraph/target/aarch64-unknown-linux-gnu/release/oxigraph_server /oxigraph/target/release/oxigraph_server ; \
else \
cargo build --release ; \
fi
FROM gcr.io/distroless/cc-debian11 FROM --platform=$TARGETPLATFORM gcr.io/distroless/cc-debian11
COPY --from=builder /oxigraph/target/release/oxigraph_server /usr/local/bin/oxigraph_server COPY --from=builder /oxigraph/target/release/oxigraph_server /usr/local/bin/oxigraph_server
ENTRYPOINT [ "/usr/local/bin/oxigraph_server" ] ENTRYPOINT [ "/usr/local/bin/oxigraph_server" ]
CMD [ "serve", "--location", "/data", "--bind", "0.0.0.0:7878" ] CMD [ "serve", "--location", "/data", "--bind", "0.0.0.0:7878" ]

Loading…
Cancel
Save