From e589388755f0edaf77bda5996ac052fde8e1e155 Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Thu, 22 May 2025 12:49:09 +1200 Subject: [PATCH 1/5] chore: `Dockerfile` use HereDoc syntax --- Dockerfile | 136 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 56 deletions(-) diff --git a/Dockerfile b/Dockerfile index 784b5c5..2e7cf37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # syntax=docker/dockerfile:1 FROM ubuntu:noble +SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"] + LABEL maintainer="Eirik Albrigtsen " LABEL org.opencontainers.image.create="$(date --utc --iso-8601=seconds)" LABEL org.opencontainers.image.documentation="https://github.com/clux/muslrust" @@ -15,91 +17,113 @@ LABEL org.opencontainers.image.description="Docker environment for building musl # - file - needed by rustup.sh install # - automake autoconf libtool - support crates building C deps as part cargo build # NB: does not include cmake atm -RUN apt-get update && apt-get install -y \ - musl-dev \ - musl-tools \ - file \ - git \ - openssh-client \ - make \ - cmake \ - g++ \ - curl \ - pkgconf \ - ca-certificates \ - automake \ - autoconf \ - libtool \ - libprotobuf-dev \ - unzip \ - --no-install-recommends && \ +RUN < Date: Thu, 22 May 2025 15:19:00 +1200 Subject: [PATCH 2/5] chore: Revise `Dockerfile` - Remove `ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse` it's the default since Rust 1.70.0 (June 2023) - Revise the rustup `RUN` and relocate relevant changes associated to it with additional PR references for maintainers as docs. - Handle `PATH` updates properly, remove any redundancy. - Remove `LD_LIBRARY_PATH`, it was misconfigured and seems redundant? - Improve the `protoc` + `sccache` bin retrieval + extraction `RUN` instructions. - Change `zlib` + `sqlite` steps into their own build stages. They each extract the source into their respective `WORKDIR`. No cleanup necessary due to separate stage. --- Dockerfile | 126 +++++++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e7cf37..47acc8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,108 +18,120 @@ LABEL org.opencontainers.image.description="Docker environment for building musl # - automake autoconf libtool - support crates building C deps as part cargo build # NB: does not include cmake atm RUN < Date: Thu, 22 May 2025 15:39:58 +1200 Subject: [PATCH 3/5] chore: `Dockerfile` - Use a separate stage for rustup Primary change is rustup `RUN` in it's own separate stage. This may not be as friendly to cache storage? Additionally breaking change that moved rustup and cargo install to `/opt` instead of in `/root`. --- Dockerfile | 85 +++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index 47acc8f..34b1fad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,6 @@ FROM ubuntu:noble SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"] -LABEL maintainer="Eirik Albrigtsen " -LABEL org.opencontainers.image.create="$(date --utc --iso-8601=seconds)" -LABEL org.opencontainers.image.documentation="https://github.com/clux/muslrust" -LABEL org.opencontainers.image.licenses="MIT" -LABEL org.opencontainers.image.url="https://github.com/clux/muslrust" -LABEL org.opencontainers.image.description="Docker environment for building musl based static rust binaries" - # Required packages: # - musl-dev, musl-tools - the musl toolchain # - curl, g++, make, pkgconf, cmake - for fetching and building third party libs @@ -43,34 +36,6 @@ HEREDOC # Common arg for arch used in urls and triples ARG AARCH -# Install rust using rustup -ARG CHANNEL -# Use specific version of Rustup: -# https://github.com/clux/muslrust/pull/63 -ARG RUSTUP_VER="1.28.2" -# Better support for running container user as non-root: -# https://github.com/clux/muslrust/pull/101 -# Uses `--no-modify-path` with PATH update + chmod on `/root` for access -ENV CARGO_BUILD_TARGET=${AARCH}-unknown-linux-musl -ENV RUSTUP_HOME=/root/.rustup -ENV PATH=/root/.cargo/bin:${PATH} -RUN < Date: Thu, 22 May 2025 15:59:08 +1200 Subject: [PATCH 4/5] fix: `Dockerfile` --- Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34b1fad..24883ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM ubuntu:noble +FROM ubuntu:noble AS base SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"] # Required packages: @@ -34,14 +34,9 @@ RUN < Date: Thu, 22 May 2025 17:10:59 +1200 Subject: [PATCH 5/5] chore: `Dockerfile` - Remove requiring a `AARCH` build arg --- Dockerfile | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 24883ff..11c1a29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,14 @@ # syntax=docker/dockerfile:1 -FROM ubuntu:noble AS base -SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"] +ARG BASE_IMAGE=ubuntu:noble + +# Mapping ARM64 / AMD64 naming conventions to equivalent `uname -a` output (build target specific): +FROM ${BASE_IMAGE} AS base-amd64 +ENV DOCKER_TARGET_ARCH=x86_64 +FROM ${BASE_IMAGE} AS base-arm64 +ENV DOCKER_TARGET_ARCH=aarch64 +FROM base-${TARGETARCH} AS base +SHELL ["/bin/bash", "-eux", "-o", "pipefail", "-c"] # Required packages: # - musl-dev, musl-tools - the musl toolchain # - curl, g++, make, pkgconf, cmake - for fetching and building third party libs @@ -33,26 +40,24 @@ RUN <