Docker cross-compilation github workflow.
This commit is contained in:
parent
01a4f68e20
commit
11d230f95a
8 changed files with 270 additions and 154 deletions
|
|
@ -1,9 +1,10 @@
|
|||
# Depends on either outputs of Dockerfile.xx or the binaries compiled elsewhere.
|
||||
FROM scratch
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
ADD https://curl.se/ca/cacert.pem /etc/ssl/cacerts.pem
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
## Assumes you are running this from respective context folder.
|
||||
COPY --chmod=755 ${TARGETPLATFORM}/rqbit /bin/rqbit
|
||||
|
||||
|
|
|
|||
42
docker/Dockerfile.xx
Normal file
42
docker/Dockerfile.xx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# Dockerfile for cross compiling rqbit binaries from scratch inside docker.
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
|
||||
|
||||
FROM --platform=$BUILDPLATFORM rust:alpine AS builder
|
||||
COPY --from=xx / /
|
||||
|
||||
RUN apk update && apk add clang lld npm python3 perl make
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
RUN xx-apk add gcc musl-dev
|
||||
|
||||
COPY / /src/
|
||||
WORKDIR /src/
|
||||
|
||||
ENV PROFILE_NAME=release-github
|
||||
ENV PROFILE_FOLDER=release-github
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry/cache \
|
||||
--mount=type=cache,target=/usr/local/cargo/registry/index \
|
||||
--mount=type=cache,target=/src/target <<EOF
|
||||
set -e
|
||||
export TT="$(xx-cargo --print-target-triple)"
|
||||
export BIN="./target/${TT}/${TT}/${PROFILE_FOLDER}/rqbit"
|
||||
|
||||
find /src/target \
|
||||
/usr/local/cargo/git/db \
|
||||
/usr/local/cargo/registry/cache \
|
||||
/usr/local/cargo/registry/index \
|
||||
-maxdepth 2 -type d
|
||||
xx-cargo build \
|
||||
--target-dir "target/${TT}" \
|
||||
--profile "${PROFILE_NAME}" \
|
||||
--no-default-features --features rust-tls,webui
|
||||
find /src/target -maxdepth 4 -type d
|
||||
xx-verify --static "${BIN}"
|
||||
mv "${BIN}" /bin/rqbit
|
||||
EOF
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /bin/rqbit /rqbit
|
||||
Loading…
Add table
Add a link
Reference in a new issue