File tree Expand file tree Collapse file tree 4 files changed +35
-8
lines changed Expand file tree Collapse file tree 4 files changed +35
-8
lines changed Original file line number Diff line number Diff line change 11[alias ]
2- xtask = " run --package xtask --bin xtask --"
2+ xtask = " run --package xtask --bin xtask --"
3+
4+ [target .aarch64-unknown-linux-musl ]
5+ linker = " aarch64-linux-gnu-gcc"
6+
7+ [target .x86_64-unknown-linux-musl ]
8+ linker = " x86_64-linux-gnu-gcc"
Original file line number Diff line number Diff line change 11# Rust related build artifacts.
22/target
3- .cargo /
43wix /
54scripts /
65examples /
Original file line number Diff line number Diff line change 1-
21# The build image
3- FROM rust:1.83.0-alpine3.20 AS weaver-build
4- RUN apk add musl-dev
2+ FROM --platform=$BUILDPLATFORM docker.io/rust:1.83.0 AS weaver-build
53WORKDIR /build
4+ ARG BUILDPLATFORM
5+ ARG TARGETPLATFORM
66
77# list out directories to avoid pulling local cargo `target/`
88COPY Cargo.toml /build/Cargo.toml
99COPY Cargo.lock /build/Cargo.lock
10+ COPY .cargo /build/.cargo
1011COPY crates /build/crates
1112COPY data /build/data
1213COPY src /build/src
1314COPY tests /build/tests
1415COPY defaults /build/defaults
16+ COPY cross-arch-build.sh /build/cross-arch-build.sh
1517
1618# Build weaver
17- RUN cargo build --release
19+ RUN ./cross-arch-build.sh
1820
1921# The runtime image
20- FROM alpine:3.20.3
22+ FROM docker.io/ alpine:3.20.3
2123LABEL maintainer="The OpenTelemetry Authors"
2224RUN addgroup weaver \
2325 && adduser \
2426 --ingroup weaver \
2527 --disabled-password \
2628 weaver
2729WORKDIR /home/weaver
28- COPY --from=weaver-build /build/target/release /weaver /weaver/weaver
30+ COPY --from=weaver-build --chown=weaver:weaver /build/weaver /weaver/weaver
2931USER weaver
3032RUN mkdir /home/weaver/target
3133ENTRYPOINT ["/weaver/weaver" ]
Original file line number Diff line number Diff line change 1+ set -exu
2+
3+ if [ " ${TARGETPLATFORM} " = " linux/amd64" ]; then
4+ RUST_TARGET=x86_64-unknown-linux-musl
5+ if [ " ${TARGETPLATFORM} " != " ${BUILDPLATFORM} " ]; then
6+ apt-get update && apt-get install -y gcc-x86-64-linux-gnu
7+ fi
8+ elif [ " ${TARGETPLATFORM} " = " linux/arm64" ]; then
9+ RUST_TARGET=aarch64-unknown-linux-musl
10+ if [ " ${TARGETPLATFORM} " != " ${BUILDPLATFORM} " ]; then
11+ apt-get update && apt-get install -y gcc-aarch64-linux-gnu
12+ fi
13+ else
14+ echo " Unsupported target platform: ${TARGETPLATFORM} "
15+ exit 1
16+ fi
17+
18+ rustup target add " ${RUST_TARGET} "
19+ cargo build --release --target=" ${RUST_TARGET} "
20+ cp " target/${RUST_TARGET} /release/weaver" .
You can’t perform that action at this time.
0 commit comments