1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2026-01-03 17:02:28 +03:00

docker: Build with musl instead of glibc

This commit is contained in:
Quentin Gliech
2022-12-16 18:24:00 +01:00
parent 834f72c155
commit f2d6fe1250
2 changed files with 8 additions and 14 deletions

View File

@@ -7,7 +7,7 @@
#
# Docker platform definitions look like this: linux/arm64 and linux/amd64, so
# there is a small script that translates those platforms to LLVM triples,
# respectively x86-64-unknown-linux-gnu and aarch64-unknown-linux-gnu
# respectively x86-64-unknown-linux-musl and aarch64-unknown-linux-musl
# The Debian version and version name must be in sync
ARG DEBIAN_VERSION=11
@@ -89,8 +89,8 @@ RUN cargo install --locked cargo-chef cargo-zigbuild cargo-auditable
# Install all cross-compilation targets
RUN rustup target add --toolchain "${RUSTC_VERSION}" \
x86_64-unknown-linux-gnu \
aarch64-unknown-linux-gnu
x86_64-unknown-linux-musl \
aarch64-unknown-linux-musl
# Helper script that transforms docker platforms to LLVM triples
COPY ./misc/docker-arch-to-rust-target.sh /
@@ -151,7 +151,7 @@ COPY ./templates/ /share/templates
##################################
## Runtime stage, debug variant ##
##################################
FROM --platform=${TARGETPLATFORM} gcr.io/distroless/base-debian${DEBIAN_VERSION}:debug-nonroot AS debug
FROM --platform=${TARGETPLATFORM} gcr.io/distroless/static-debian${DEBIAN_VERSION}:debug-nonroot AS debug
COPY --from=builder /usr/local/bin/mas-cli /usr/local/bin/mas-cli
COPY --from=share /share /usr/local/share/mas-cli
@@ -162,7 +162,7 @@ ENTRYPOINT ["/usr/local/bin/mas-cli"]
###################
## Runtime stage ##
###################
FROM --platform=${TARGETPLATFORM} gcr.io/distroless/base-debian${DEBIAN_VERSION}:nonroot
FROM --platform=${TARGETPLATFORM} gcr.io/distroless/static-debian${DEBIAN_VERSION}:nonroot
COPY --from=builder /usr/local/bin/mas-cli /usr/local/bin/mas-cli
COPY --from=share /share /usr/local/share/mas-cli

View File

@@ -5,16 +5,10 @@ if [ "$#" -ne 1 ]; then
exit 1
fi
if [ "$1" = "linux/arm64" -o "$1" = "linux/arm64/v8" ]; then
echo "aarch64-unknown-linux-gnu"
elif [ "$1" = "linux/arm" -o "$1" = "linux/arm/v7" ]; then
echo "armv7-unknown-linux-gnueabihf"
elif [ "$1" = "linux/arm/v6" ]; then
echo "arm-unknown-linux-gnueabihf"
if [ "$1" = "linux/arm64" ] || [ "$1" = "linux/arm64/v8" ]; then
echo "aarch64-unknown-linux-musl"
elif [ "$1" = "linux/amd64" ]; then
echo "x86_64-unknown-linux-gnu"
elif [ "$1" = "linux/i386" ]; then
echo "i686-unknown-linux-gnu"
echo "x86_64-unknown-linux-musl"
else
echo "unsupported platform $1" >&2
exit 2