diff --git a/Dockerfile b/Dockerfile index 784b5c5..11c1a29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ # syntax=docker/dockerfile:1 -FROM ubuntu:noble -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" +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 @@ -15,98 +17,146 @@ 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 && \ - rm -rf /var/lib/apt/lists/* - -# Common arg for arch used in urls and triples -ARG AARCH -# Install rust using rustup -ARG CHANNEL -ENV RUSTUP_VER="1.28.2" \ - RUST_ARCH="${AARCH}-unknown-linux-gnu" \ - CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse +RUN <