image(broker): install musl target AFTER rust-toolchain.toml is copied
Ordering matters. `rust:1.96-slim` ships with toolchain 1.96 already installed under one identifier, but rust-toolchain.toml (channel = 1.96.0) can prompt rustup to resolve to a distinct pinned toolchain. `rustup target add` runs BEFORE rust-toolchain.toml lands, so it adds musl to the wrong toolchain — cargo's later build picks up the workspace pin and can't find core for the target. Move the COPY of rust-toolchain.toml before the rustup target add so the target lands on the toolchain cargo actually uses. Matches server.Dockerfile's known-working structure.
This commit is contained in:
@@ -2,14 +2,10 @@
|
|||||||
# Shares the builder pattern with the server image; ships ONLY the broker
|
# Shares the builder pattern with the server image; ships ONLY the broker
|
||||||
# binary.
|
# binary.
|
||||||
FROM rust:1.96-slim AS builder
|
FROM rust:1.96-slim AS builder
|
||||||
|
ARG TARGETARCH
|
||||||
# git + cmake are needed for the clawhdf5 git dependency (fetched via the git
|
# git + cmake are needed for the clawhdf5 git dependency (fetched via the git
|
||||||
# CLI — libgit2 chokes on Gitea smart-HTTP) and its zlib-ng C build (cmake).
|
# CLI — libgit2 chokes on Gitea smart-HTTP) and its zlib-ng C build (cmake).
|
||||||
RUN case "$(uname -m)" in \
|
RUN apt-get update \
|
||||||
aarch64) echo aarch64-unknown-linux-musl > /rust-target ;; \
|
|
||||||
*) echo x86_64-unknown-linux-musl > /rust-target ;; \
|
|
||||||
esac \
|
|
||||||
&& rustup target add "$(cat /rust-target)" \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends musl-tools git cmake make pkg-config \
|
&& apt-get install -y --no-install-recommends musl-tools git cmake make pkg-config \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
@@ -19,6 +15,15 @@ COPY tools ./tools
|
|||||||
COPY images/seccomp ./images/seccomp
|
COPY images/seccomp ./images/seccomp
|
||||||
COPY migrations ./migrations
|
COPY migrations ./migrations
|
||||||
COPY .sqlx ./.sqlx
|
COPY .sqlx ./.sqlx
|
||||||
|
# Install the musl target AFTER rust-toolchain.toml is in place, so rustup adds
|
||||||
|
# it to the toolchain the workspace pins (channel 1.96.0), not the base image's
|
||||||
|
# default. Doing this before the COPY installs into a toolchain cargo won't
|
||||||
|
# actually use, and the build then fails with E0463 (no core for musl).
|
||||||
|
RUN case "$TARGETARCH" in \
|
||||||
|
arm64) echo aarch64-unknown-linux-musl > /rust-target ;; \
|
||||||
|
*) echo x86_64-unknown-linux-musl > /rust-target ;; \
|
||||||
|
esac \
|
||||||
|
&& rustup target add "$(cat /rust-target)"
|
||||||
ENV SQLX_OFFLINE=true
|
ENV SQLX_OFFLINE=true
|
||||||
# Fetch git deps with the system git (libgit2 fails against Gitea smart-HTTP);
|
# Fetch git deps with the system git (libgit2 fails against Gitea smart-HTTP);
|
||||||
# build the zlib-ng C dep with the musl cross compiler for the static target.
|
# build the zlib-ng C dep with the musl cross compiler for the static target.
|
||||||
|
|||||||
Reference in New Issue
Block a user