simplify docker build to build only for amd64

This commit is contained in:
Letro Bot
2026-04-08 09:32:54 +03:30
parent a152c28202
commit b80e0c3c4b
3 changed files with 9 additions and 23 deletions

View File

@@ -267,6 +267,7 @@ jobs:
cwd://${{ steps.meta.outputs.bake-file }} cwd://${{ steps.meta.outputs.bake-file }}
cwd://${{ steps.meta-debug.outputs.bake-file }} cwd://${{ steps.meta-debug.outputs.bake-file }}
set: | set: |
base.platforms=linux/amd64
base.output=type=image,push=true base.output=type=image,push=true
base.cache-from=type=registry,ref=${{ env.BUILDCACHE }}:buildcache base.cache-from=type=registry,ref=${{ env.BUILDCACHE }}:buildcache
base.cache-to=type=registry,ref=${{ env.BUILDCACHE }}:buildcache,mode=max base.cache-to=type=registry,ref=${{ env.BUILDCACHE }}:buildcache,mode=max

View File

@@ -5,10 +5,7 @@
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial # SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
# Please see LICENSE files in the repository root for full details. # Please see LICENSE files in the repository root for full details.
# Builds a minimal image with the binary only. It is multi-arch capable, # Builds a minimal image with the binary only for amd64.
# cross-building to aarch64 and x86_64. When cross-compiling, Docker sets two
# implicit BUILDARG: BUILDPLATFORM being the host platform and TARGETPLATFORM
# being the platform being built.
# The Debian version and version name must be in sync # The Debian version and version name must be in sync
ARG DEBIAN_VERSION=13 ARG DEBIAN_VERSION=13
@@ -76,13 +73,12 @@ RUN --network=default \
cargo install --locked \ cargo install --locked \
cargo-auditable@=${CARGO_AUDITABLE_VERSION} cargo-auditable@=${CARGO_AUDITABLE_VERSION}
# Install all cross-compilation targets # Install the cross-compilation target used for the image
# Network access: to download the targets # Network access: to download the target
RUN --network=default \ RUN --network=default \
rustup target add \ rustup target add \
--toolchain "${RUSTC_VERSION}" \ --toolchain "${RUSTC_VERSION}" \
x86_64-unknown-linux-gnu \ x86_64-unknown-linux-gnu
aarch64-unknown-linux-gnu
RUN --network=none \ RUN --network=none \
dpkg --add-architecture arm64 && \ dpkg --add-architecture arm64 && \
@@ -90,21 +86,15 @@ RUN --network=none \
ARG BUILDPLATFORM ARG BUILDPLATFORM
# Install cross-compilation toolchains for all supported targets # Install the cross-compilation toolchain for amd64
# Network access: to install apt packages # Network access: to install apt packages
RUN --network=default \ RUN --network=default \
apt-get update && apt-get install -y \ apt-get update && apt-get install -y \
$(if [ "${BUILDPLATFORM}" != "linux/arm64" ]; then echo "g++-aarch64-linux-gnu"; fi) \
$(if [ "${BUILDPLATFORM}" != "linux/amd64" ]; then echo "g++-x86-64-linux-gnu"; fi) \
libc6-dev-amd64-cross \ libc6-dev-amd64-cross \
libc6-dev-arm64-cross \
g++ g++
# Setup the cross-compilation environment # Setup the cross-compilation environment
ENV \ ENV \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc \ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc \
CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc \ CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc \
CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++ CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++
@@ -130,9 +120,7 @@ RUN --network=default \
--no-default-features \ --no-default-features \
--features docker \ --features docker \
--target x86_64-unknown-linux-gnu \ --target x86_64-unknown-linux-gnu \
--target aarch64-unknown-linux-gnu \ && mv "target/x86_64-unknown-linux-gnu/release/mas-cli" /usr/local/bin/mas-cli
&& mv "target/x86_64-unknown-linux-gnu/release/mas-cli" /usr/local/bin/mas-cli-amd64 \
&& mv "target/aarch64-unknown-linux-gnu/release/mas-cli" /usr/local/bin/mas-cli-arm64
####################################### #######################################
## Prepare /usr/local/share/mas-cli/ ## ## Prepare /usr/local/share/mas-cli/ ##
@@ -149,8 +137,7 @@ COPY ./translations/ /share/translations
################################## ##################################
FROM gcr.io/distroless/cc-debian${DEBIAN_VERSION}:debug-nonroot AS debug FROM gcr.io/distroless/cc-debian${DEBIAN_VERSION}:debug-nonroot AS debug
ARG TARGETARCH COPY --from=builder /usr/local/bin/mas-cli /usr/local/bin/mas-cli
COPY --from=builder /usr/local/bin/mas-cli-${TARGETARCH} /usr/local/bin/mas-cli
COPY --from=share /share /usr/local/share/mas-cli COPY --from=share /share /usr/local/share/mas-cli
WORKDIR / WORKDIR /
@@ -161,8 +148,7 @@ ENTRYPOINT ["/usr/local/bin/mas-cli"]
################### ###################
FROM gcr.io/distroless/cc-debian${DEBIAN_VERSION}:nonroot FROM gcr.io/distroless/cc-debian${DEBIAN_VERSION}:nonroot
ARG TARGETARCH COPY --from=builder /usr/local/bin/mas-cli /usr/local/bin/mas-cli
COPY --from=builder /usr/local/bin/mas-cli-${TARGETARCH} /usr/local/bin/mas-cli
COPY --from=share /share /usr/local/share/mas-cli COPY --from=share /share /usr/local/share/mas-cli
WORKDIR / WORKDIR /

View File

@@ -29,7 +29,6 @@ target "base" {
platforms = [ platforms = [
"linux/amd64", "linux/amd64",
// "linux/arm64",
] ]
} }