From bd35ec2e520ec6c6f60f6bf78ccafe7515a6e3e8 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Sat, 27 Sep 2025 02:01:57 +0200 Subject: [PATCH 01/19] chore: draft for multiarch image --- Dockerfile | 57 ++++++++-- Dockerfile.cross | 191 +++++++++++++++++++++++++++++++++ Makefile | 138 ++++++++++++++++++++---- README.md | 28 ++--- cargo/config.toml | 3 - scripts/git-credential-ghtoken | 79 -------------- tests/openssl/Cargo.lock | 156 +++++++++++++++++++++++++++ tests/openssl/Cargo.toml | 11 ++ tests/openssl/src/main.rs | 18 ++++ tests/zlib/Cargo.lock | 57 ++++++---- tests/zlib/Cargo.toml | 2 +- 11 files changed, 591 insertions(+), 149 deletions(-) create mode 100644 Dockerfile.cross delete mode 100755 scripts/git-credential-ghtoken create mode 100644 tests/openssl/Cargo.lock create mode 100644 tests/openssl/Cargo.toml create mode 100644 tests/openssl/src/main.rs diff --git a/Dockerfile b/Dockerfile index 0558534..46121a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # NOTE: Most of Dockerfile and related were borrowed from https://hub.docker.com/r/ekidd/rust-musl-builder -FROM debian:12.11-slim +FROM debian:12.12-slim ARG VERSION=0.0.0 ENV VERSION=${VERSION} @@ -19,15 +19,17 @@ RUN set -eux \ && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ autoconf \ automake \ + bison \ build-essential \ ca-certificates \ clang \ cmake \ curl \ file \ + flex \ + g++-aarch64-linux-gnu \ gcc-aarch64-linux-gnu \ gcc-arm-linux-gnueabihf \ - g++-aarch64-linux-gnu \ git \ libbz2-dev \ libgmp-dev \ @@ -43,15 +45,15 @@ RUN set -eux \ llvm-dev \ lzma-dev \ musl-dev \ - musl-dev:armhf \ musl-dev:arm64 \ + musl-dev:armhf \ musl-tools \ patch \ pkgconf \ python3 \ xutils-dev \ - yasm \ xz-utils \ + yasm \ zlib1g-dev \ # Clean up local repository of retrieved packages and remove the package lists && apt-get clean \ @@ -80,7 +82,7 @@ RUN set -eux \ # the popular Rust `hyper` crate. # OpenSSL 1.1.1 - https://github.com/openssl/openssl/releases -ARG OPENSSL_VERSION=1.1.1w +ARG OPENSSL_VERSION=3.5.3 # We point /usr/local/musl/include/linux at some Linux kernel headers (not # necessarily the right ones) in an effort to compile OpenSSL 1.1's "engine" @@ -100,8 +102,7 @@ RUN set -eux \ && ln -s "/usr/include/$(uname -m)-linux-gnu/asm" /usr/local/musl/include/asm \ && ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic \ && cd /tmp \ - && ver=$(echo $OPENSSL_VERSION | sed -e 's:\.:_:g') \ - && curl -LO "https://github.com/openssl/openssl/releases/download/OpenSSL_${ver}/openssl-${OPENSSL_VERSION}.tar.gz" \ + && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ && cd "openssl-${OPENSSL_VERSION}" \ && env CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY ${config} "linux-$(uname -m)" \ @@ -109,11 +110,27 @@ RUN set -eux \ && env C_INCLUDE_PATH=/usr/local/musl/include/ make -j$(nproc) \ && make -j$(nproc) install_sw \ && make -j$(nproc) install_ssldirs \ - && rm /usr/local/musl/include/linux /usr/local/musl/include/asm /usr/local/musl/include/asm-generic \ && openssl version \ + && rm -rf \ + /usr/local/musl/include/linux \ + /usr/local/musl/include/asm \ + /usr/local/musl/include/asm-generic \ + && ls -l /usr/local/musl \ + && if [ "$(uname -m)" = "x86_64" ]; then \ + ln -s /usr/local/musl/lib64 /usr/local/musl/lib; \ + fi \ && rm -r /tmp/* \ && true +RUN set -eux \ + && echo "Testing musl-gcc with OpenSSL..." \ + && openssl version \ + && echo "int main(){return 0;}" | \ + musl-gcc -o test -x c - \ + -I/usr/local/musl/include \ + -L/usr/local/musl/lib \ + -lssl -lcrypto \ + && true # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 @@ -132,7 +149,22 @@ RUN set -eux \ # libpq - https://ftp.postgresql.org/pub/source/ -ARG POSTGRESQL_VERSION=15.9 +ARG POSTGRESQL_VERSION=17.6 +ARG ICU4C_VERSION=77.1 + +RUN set -eux \ + && echo "Building icu4c..." \ + && cd /tmp \ + && ver1=$(echo $ICU4C_VERSION | sed -e 's:\.:-:g') \ + && ver2=$(echo $ICU4C_VERSION | sed -e 's:\.:_:g') \ + && curl -LO https://github.com/unicode-org/icu/releases/download/release-${ver1}/icu4c-${ver2}-src.tgz \ + && tar xf icu4c-${ver2}-src.tgz \ + && cd icu/source \ + && env CC=musl-gcc CXX=musl-g++ ./configure --prefix=/usr/local/musl \ + && make -j$(nproc) \ + && make -j$(nproc) install \ + && rm -r /tmp/* \ + && true RUN set -eux \ && echo "Building libpq ${POSTGRESQL_VERSION}..." \ @@ -206,6 +238,8 @@ RUN set -eux \ ENV PATH=$PATH:/usr/local/osxcross/target/bin ENV MACOSX_DEPLOYMENT_TARGET=${OSX_VERSION_MIN} ENV OSXCROSS_MACPORTS_MIRROR=https://packages.macports.org +ENV OSXCROSS_MACPORTS_LOCAL=/usr/local/osxcross/target/macports/pkgs/opt/local +ENV OSXCROSS_MACPORTS_LIBEXEC=${OSXCROSS_MACPORTS_LOCAL}/libexec RUN set -eux \ && echo "Testing osxcross with compiler-rt..." \ @@ -217,10 +251,11 @@ RUN set -eux \ && echo "Install dependencies via osxcross tools..." \ && apt-get update \ && /usr/local/osxcross/tools/get_dependencies.sh \ + && osxcross-macports install zlib openssl3 \ && true # Rust stable toolchain -ARG TOOLCHAIN=1.86.0 +ARG TOOLCHAIN=1.87.0 # Install our Rust toolchain and the `musl` target. We patch the # command-line we pass to the installer so that it won't attempt to @@ -236,7 +271,7 @@ RUN set -eux \ x86_64-apple-darwin \ x86_64-unknown-linux-musl \ && true -COPY cargo/config.toml /root/.cargo/config +COPY cargo/config.toml /root/.cargo/config.toml RUN set -eux \ && echo "Removing temp files..." \ diff --git a/Dockerfile.cross b/Dockerfile.cross new file mode 100644 index 0000000..ac7392f --- /dev/null +++ b/Dockerfile.cross @@ -0,0 +1,191 @@ +FROM joseluisq/docker-osxcross:1.0.0-beta.1 + +ARG VERSION=0.0.0 +ENV VERSION=${VERSION} + +LABEL version="${VERSION}" \ + description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + +# Static linking for C++ code +RUN set -eux \ + && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ + # Create appropriate directories for current user + && mkdir -p /root/libs /root/src \ + && true + +ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH + +##### Rust toolchains + +# Rust/Cargo related environment variables +ENV TARGET=musl +# Crate-related environment variables +ENV LIBZ_SYS_STATIC=1 + +# Rust stable toolchain +ARG TOOLCHAIN=1.87.0 + +RUN set -eux \ + && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ + && rustup target add \ + aarch64-apple-darwin \ + aarch64-unknown-linux-gnu \ + aarch64-unknown-linux-musl \ + x86_64-apple-darwin \ + x86_64-unknown-linux-musl \ + && true + +COPY cargo/config.toml /root/.cargo/config.toml + +RUN set -eux \ + && rustc -vV \ + && cargo -vV \ + && true + +##### Libraries + +# zlib - http://zlib.net/ +ARG ZLIB_VERSION=1.3.1 + +WORKDIR /tmp + +RUN set -eux \ + && echo "Downloading zlib ${ZLIB_VERSION}..." \ + && cd /tmp \ + && curl -LO "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ + && tar xzf "zlib-${ZLIB_VERSION}.tar.gz" \ + && rm -rf "zlib-${ZLIB_VERSION}.tar.gz" \ + && true + +WORKDIR /tmp/zlib-${ZLIB_VERSION} + +# x86_64 glibc +RUN set -eux \ + && make distclean \ + && CC=gcc ./configure --prefix=/usr/local/x86_64-linux-gnu \ + && make -j$(nproc) \ + && make install \ + && true + +# arm64 glibc +RUN set -eux \ + && make distclean \ + && CC=aarch64-linux-gnu-gcc ./configure --prefix=/usr/local/aarch64-linux-gnu \ + && make -j$(nproc) \ + && make install \ + && true + +# x86_64 musl +RUN set -eux \ + && make distclean \ + && CC=musl-gcc ./configure --static --prefix=/usr/local/x86_64-linux-musl \ + && make -j$(nproc) \ + && make install \ + && true + +WORKDIR /tmp + +# OpenSSL 3.5.3 - https://github.com/openssl/openssl/releases +ARG OPENSSL_VERSION=3.5.3 + +RUN set -eux \ + && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ + && true + +# We point /usr/local/musl/include/linux at some Linux kernel headers (not +# necessarily the right ones) in an effort to compile OpenSSL 1.1's "engine" +# component. It's possible that this will cause bizarre and terrible things to +# happen. There may be "sanitized" header +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \ + && ls /usr/include/linux \ + && mkdir -p /usr/local/x86_64-linux-musl/include \ + && ln -s /usr/include/linux /usr/local/x86_64-linux-musl/include/linux \ + && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ + && ln -s /usr/include/asm-generic /usr/local/x86_64-linux-musl/include/asm-generic \ + && env CC=musl-gcc ./Configure no-shared no-zlib \ + -fPIC --prefix=/usr/local/x86_64-linux-musl \ + -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ + && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && openssl version \ + && rm -rf \ + /usr/local/x86_64-linux-musl/include/linux \ + /usr/local/x86_64-linux-musl/include/asm \ + /usr/local/x86_64-linux-musl/include/asm-generic \ + && ls -l /usr/local/x86_64-linux-musl \ + && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \ + ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ + else \ + mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \ + mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ + cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \ + unlink /usr/local/x86_64-linux-musl/lib/lib64; \ + rm -rf /usr/local/x86_64-linux-musl/abc; \ + fi \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64..." \ + && ls /usr/include/linux \ + && mkdir -p /usr/local/aarch64-linux-gnu/include \ + # && ln -s /usr/include/linux /usr/local/aarch64-linux-gnu/include/linux \ + # && ln -s "/usr/include/aarch64-linux-gnu/asm" /usr/local/aarch64-linux-gnu/include/asm \ + # && ln -s /usr/include/asm-generic /usr/local/aarch64-linux-gnu/include/asm-generic \ + && env CC=aarch64-linux-gnu-gcc ./Configure no-shared no-zlib \ + -fPIC --prefix=/usr/local/aarch64-linux-gnu \ + -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && openssl version \ + && rm -rf \ + /usr/local/aarch64-linux-gnu/include/linux \ + /usr/local/aarch64-linux-gnu/include/asm \ + /usr/local/aarch64-linux-gnu/include/asm-generic \ + && ls -l /usr/local/aarch64-linux-gnu \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && echo "Testing musl-gcc with OpenSSL..." \ + && openssl version \ + && echo "int main(){return 0;}" | \ + musl-gcc -o test -x c - \ + -I/usr/local/x86_64-linux-musl/include \ + -L/usr/local/x86_64-linux-musl/lib \ + -lssl -lcrypto \ + && true + +WORKDIR /root + +# OpenSSL related environment variables +ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu +ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 + +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=true \ + PKG_CONFIG_ALL_STATIC=true + +RUN set -eux \ + && echo "Removing temp files..." \ + && rm -rf *~ taballs *.tar.xz \ + && rm -rf /tmp/* \ + && true + +WORKDIR /root/src + +CMD ["bash"] diff --git a/Makefile b/Makefile index 68f71da..31a6919 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,28 @@ build: -f Dockerfile . .PHONY: build +build-osxcross: + docker build \ + -t $(REPOSITORY)/rust-linux-darwin-builder:osxcross \ + --network=host \ + -f Dockerfile . +.PHONY: build-osxcross + +build-cross: + docker build \ + -t $(REPOSITORY)/rust-linux-darwin-builder:cross \ + --network=host \ + -f Dockerfile.cross . +.PHONY: build-cross + +run-cross: + @docker run --rm -it \ + -v $(PWD):/root/src \ + -v $(PWD)/cargo/config.toml:/root/.cargo/config.toml \ + -w /root/src \ + $(REPOSITORY)/rust-linux-darwin-builder:cross \ + bash +.PHONY: run-cross # Use to build both arm64 and amd64 images at the same time. # WARNING! Will automatically push, since multi-platform images are not available locally. @@ -25,12 +47,20 @@ buildx: .PHONY: buildx +run: + @docker run --rm -it \ + -v $(PWD):/root/src \ + -w /root/src \ + $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ + bash +.PHONY: run + test: @docker run --rm \ -v $(PWD):/root/src \ -w /root/src \ $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ - bash -c 'set -eu; make test-ci' + bash -c 'set -eu; make test-ci; make test-openssl' .PHONY: test test-ci: @@ -45,86 +75,156 @@ test-ci: && if [ "$$(uname -m)" = "x86_64" ]; then \ echo "Compiling application (linux-gnu x86_64)..."; \ cargo build --release --target x86_64-unknown-linux-gnu; \ - du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test; \ target/x86_64-unknown-linux-gnu/release/hello-world-test; \ + du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test; \ + file target/x86_64-unknown-linux-gnu/release/hello-world-test; \ echo; \ \ echo "Compiling application (linux-musl x86_64)..."; \ cargo build --release --target x86_64-unknown-linux-musl; \ - du -sh target/x86_64-unknown-linux-musl/release/hello-world-test; \ target/x86_64-unknown-linux-musl/release/hello-world-test; \ + du -sh target/x86_64-unknown-linux-musl/release/hello-world-test; \ + file target/x86_64-unknown-linux-musl/release/hello-world-test; \ echo; \ fi \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ && cargo build --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/hello-world-test \ + && file target/x86_64-apple-darwin/release/hello-world-test \ && echo \ -\ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ && cargo build --release --target aarch64-unknown-linux-gnu \ - && du -sh target/aarch64-unknown-linux-gnu/release/hello-world-test \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-gnu/release/hello-world-test; \ fi \ + && du -sh target/aarch64-unknown-linux-gnu/release/hello-world-test \ + && file target/aarch64-unknown-linux-gnu/release/hello-world-test \ && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ && cargo build --release --target aarch64-unknown-linux-musl \ - && du -sh target/aarch64-unknown-linux-musl/release/hello-world-test \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-musl/release/hello-world-test; \ fi \ + && du -sh target/aarch64-unknown-linux-musl/release/hello-world-test \ + && file target/aarch64-unknown-linux-musl/release/hello-world-test \ && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ && cargo build --release --target aarch64-apple-darwin \ - && du -sh target/aarch64-apple-darwin/release/hello-world-test + && du -sh target/aarch64-apple-darwin/release/hello-world-test \ + && file target/aarch64-apple-darwin/release/hello-world-test +.ONESHELL: test-ci + +test-zlib: + @echo "Checking Debian version..." + @cat /etc/debian_version + @echo + @echo "Testing cross-compiling zlib application..." + @rustc -vV @echo - @cd ../.. @cd tests/zlib \ \ && if [ "$$(uname -m)" = "x86_64" ]; then \ echo "Compiling application (linux-gnu x86_64)..."; \ cargo build --release --target x86_64-unknown-linux-gnu; \ - du -sh target/x86_64-unknown-linux-gnu/release/zlib-test; \ target/x86_64-unknown-linux-gnu/release/zlib-test; \ + du -sh target/x86_64-unknown-linux-gnu/release/zlib-test; \ + file target/x86_64-unknown-linux-gnu/release/zlib-test; \ echo; \ \ echo "Compiling application (linux-musl x86_64)..."; \ cargo build --release --target x86_64-unknown-linux-musl; \ - du -sh target/x86_64-unknown-linux-musl/release/zlib-test; \ target/x86_64-unknown-linux-musl/release/zlib-test; \ + du -sh target/x86_64-unknown-linux-musl/release/zlib-test; \ + file target/x86_64-unknown-linux-musl/release/zlib-test; \ echo; \ fi \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ - && LIBZ_SYS_STATIC=0 CC=o64-clang CXX=o64-clang++ \ + && LIBZ_SYS_STATIC=1 CC=o64-clang CXX=o64-clang++ \ cargo build --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/zlib-test \ - && echo \ -\ + && file target/x86_64-apple-darwin/release/zlib-test \ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ - && cargo build --release --target aarch64-unknown-linux-gnu \ - && du -sh target/aarch64-unknown-linux-gnu/release/zlib-test \ + && CC=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-gnu/release/zlib-test; \ fi \ + && du -sh target/aarch64-unknown-linux-gnu/release/zlib-test \ + && file target/aarch64-unknown-linux-gnu/release/zlib-test \ && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ && cargo build --release --target aarch64-unknown-linux-musl \ - && du -sh target/aarch64-unknown-linux-musl/release/zlib-test \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-musl/release/zlib-test; \ fi \ + && du -sh target/aarch64-unknown-linux-musl/release/zlib-test \ + && file target/aarch64-unknown-linux-musl/release/zlib-test \ && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ - && LIBZ_SYS_STATIC=0 CC=o64-clang CXX=o64-clang++ \ + && LIBZ_SYS_STATIC=1 CC=oa64-clang CXX=oa64-clang++ \ cargo build --release --target aarch64-apple-darwin \ - && du -sh target/aarch64-apple-darwin/release/zlib-test + && du -sh target/aarch64-apple-darwin/release/zlib-test \ + && file target/aarch64-apple-darwin/release/zlib-test -.ONESHELL: test-ci +.ONESHELL: test-zlib + +test-openssl: + @echo "Checking Debian version..." + @cat /etc/debian_version + @echo + @echo "Testing cross-compiling openssl application..." + @rustc -vV + @echo + @cd tests/openssl \ +\ + && if [ "$$(uname -m)" = "x86_64" ]; then \ + echo "Compiling application (linux-gnu x86_64)..."; \ + cargo build --release --target x86_64-unknown-linux-gnu; \ + target/x86_64-unknown-linux-gnu/release/openssl; \ + du -sh target/x86_64-unknown-linux-gnu/release/openssl; \ + file target/x86_64-unknown-linux-gnu/release/openssl; \ + echo; \ +\ + echo "Compiling application (linux-musl x86_64)..."; \ + cargo build --release --target x86_64-unknown-linux-musl; \ + target/x86_64-unknown-linux-musl/release/openssl; \ + du -sh target/x86_64-unknown-linux-musl/release/openssl; \ + file target/x86_64-unknown-linux-musl/release/openssl; \ + echo; \ + fi \ +\ + && echo "Cross-compiling application (apple-darwin x86_64)..." \ + && OPENSSL_STATIC=1 \ + CC=o64-clang CXX=o64-clang++ \ + cargo build --release --target x86_64-apple-darwin \ + && du -sh target/x86_64-apple-darwin/release/openssl \ + && file target/x86_64-apple-darwin/release/openssl \ + && echo \ +\ + && echo "Cross-compiling application (linux-musl aarch64)..." \ + && cargo build --release --target aarch64-unknown-linux-musl \ + && if [ "$$(uname -m)" = "arm64" ]; then \ + target/aarch64-unknown-linux-musl/release/openssl; \ + fi \ + && du -sh target/aarch64-unknown-linux-musl/release/openssl \ + && file target/aarch64-unknown-linux-musl/release/openssl \ + && echo \ +\ + && echo "Cross-compiling application (apple-darwin aarch64)..." \ + && CC=oa64-clang CXX=oa64-clang++ \ + cargo build --release --target aarch64-apple-darwin \ + && if [ "$$(uname -m)" = "arm64" ]; then \ + target/aarch64-apple-darwin/release/openssl; \ + fi \ + && du -sh target/aarch64-apple-darwin/release/openssl \ + && file target/aarch64-apple-darwin/release/openssl \ + && echo \ + && echo "Cross-compiling done." +.ONESHELL: test-openssl diff --git a/README.md b/README.md index 3993d74..84c2bd4 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Below are the default toolchains included in the Docker image. docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ sh -c "cargo build --release --target x86_64-unknown-linux-musl" ``` @@ -52,7 +52,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ sh -c "cargo build --release --target x86_64-unknown-linux-gnu" ``` @@ -62,7 +62,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ sh -c "cargo build --release --target x86_64-apple-darwin" ``` @@ -74,7 +74,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ sh -c "cargo build --release --target aarch64-unknown-linux-gnu" ``` @@ -84,7 +84,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ sh -c "cargo build --release --target aarch64-unknown-linux-musl" ``` @@ -94,7 +94,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ sh -c "cargo build --release --target aarch64-apple-darwin" ``` @@ -107,7 +107,7 @@ It's known that the [`CARGO_HOME`](https://doc.rust-lang.org/cargo/guide/cargo-h You can also use the image as a base for your Dockerfile: ```Dockerfile -FROM joseluisq/rust-linux-darwin-builder:1.86.0 +FROM joseluisq/rust-linux-darwin-builder:1.87.0 ``` ### OSXCross @@ -150,7 +150,7 @@ compile: @docker run --rm -it \ -v $(PWD):/app/src \ -w /app/src \ - joseluisq/rust-linux-darwin-builder:1.86.0 \ + joseluisq/rust-linux-darwin-builder:1.87.0 \ make cross-compile .PHONY: compile @@ -172,14 +172,14 @@ cross-compile: Just run the makefile `compile` target, then you will see two release binaries `x86_64-unknown-linux-musl` and `x86_64-apple-darwin`. ```sh -make compile -# rustc 1.86.0 (05f9846f8 2025-03-31) +# make compile +# rustc 1.87.0 (17067e9ac 2025-05-09) # binary: rustc -# commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb -# commit-date: 2025-03-31 +# commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359 +# commit-date: 2025-05-09 # host: x86_64-unknown-linux-gnu -# release: 1.86.0 -# LLVM version: 19.1.7 +# release: 1.87.0 +# LLVM version: 20.1.1 # 2. Compiling application (linux-musl x86_64)... # Finished release [optimized] target(s) in 0.01s diff --git a/cargo/config.toml b/cargo/config.toml index 521423f..492c816 100644 --- a/cargo/config.toml +++ b/cargo/config.toml @@ -2,9 +2,6 @@ # Target musl-libc by default when running Cargo target = "x86_64-unknown-linux-musl" -[target.armv7-unknown-linux-musleabihf] -linker = "arm-linux-gnueabihf-gcc" - [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" diff --git a/scripts/git-credential-ghtoken b/scripts/git-credential-ghtoken deleted file mode 100755 index 20a8fd0..0000000 --- a/scripts/git-credential-ghtoken +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# Usage: git-credential-ghtoken -# -# Allows `git` to authenticate with GitHub using `GH_USER` and `GH_TOKEN` -# environment variables. -# -# To install this: -# -# git config --global credential.https://github.com.helper \ -# "$(pwd)/scripts/git-credential-ghtoken" -# -# Or copy it into your path and run: -# -# git config --global credential.https://github.com.helper ghtoken -# -# -# Copyright (c) 2018 Faraday, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# Standard paranoia. -set -euo pipefail - -# Parse our command-line arguments. -operation="$1" - -# Ignore all operations besides `get`. -if [ "$operation" != get ]; then - exit 0 -fi - -# Quit now if we don't have the necessary environment variables. -if [ ! -v GH_USER ] || [ ! -v GH_TOKEN ]; then - exit 0 -fi - -# Parse the input we receive from `git`. -while read line; do - var="$(echo "$line" | sed 's/=.*$//')" - val="$(echo "$line" | sed 's/^.*=//')" - case "$var" in - # Only send credentials over HTTPS. - protocol) - if [ "$val" != https ]; then - exit 0 - fi - ;; - # Only send credentials to GitHub (just extra paranoia; change as - # needed). - host) - if [ "$val" != github.com ]; then - exit 0 - fi - ;; - esac -done - -# Output our credentials. -cat <"] +edition = "2018" + +[dependencies] +openssl = { version = "0.10.73" } + +[profile.release] +lto = true diff --git a/tests/openssl/src/main.rs b/tests/openssl/src/main.rs new file mode 100644 index 0000000..7aaba02 --- /dev/null +++ b/tests/openssl/src/main.rs @@ -0,0 +1,18 @@ +use openssl::aes::{unwrap_key, wrap_key, AesKey}; + +fn main() { + let kek = b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; + let key_to_wrap = b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"; + + let enc_key = AesKey::new_encrypt(kek).unwrap(); + let mut ciphertext = [0u8; 24]; + wrap_key(&enc_key, None, &mut ciphertext, &key_to_wrap[..]).unwrap(); + + let dec_key = AesKey::new_decrypt(kek).unwrap(); + let mut orig_key = [0u8; 16]; + unwrap_key(&dec_key, None, &mut orig_key, &ciphertext[..]).unwrap(); + + assert_eq!(&orig_key[..], &key_to_wrap[..]); + + println!("OpenSSL AES key wrapping tested sucessfully!") +} diff --git a/tests/zlib/Cargo.lock b/tests/zlib/Cargo.lock index ddddd3f..26d337b 100644 --- a/tests/zlib/Cargo.lock +++ b/tests/zlib/Cargo.lock @@ -1,42 +1,49 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "cc" -version = "1.0.83" +version = "1.2.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "80f41ae168f955c12fb8960b057d70d0ca153fb83182b57d86380443527be7e9" dependencies = [ - "libc", + "find-msvc-tools", + "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" dependencies = [ "cfg-if", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" + [[package]] name = "flate2" -version = "1.0.27" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", "libz-sys", @@ -45,15 +52,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" dependencies = [ "cc", "libc", @@ -63,18 +70,24 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ - "adler", + "adler2", ] [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "vcpkg" diff --git a/tests/zlib/Cargo.toml b/tests/zlib/Cargo.toml index 021dabe..5dd611a 100644 --- a/tests/zlib/Cargo.toml +++ b/tests/zlib/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Jose Quintana "] edition = "2021" [dependencies] -flate2 = { version = "1.0", features = [ "zlib-default" ] } +flate2 = { version = "1.1.2", features = [ "zlib-default" ] } [profile.release] lto = true From cb84e4caf593639d089cbe20a493d9ced8e2e582 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Tue, 30 Sep 2025 00:10:19 +0200 Subject: [PATCH 02/19] refactor: dockerfiles & fix openssl3 binary for x86_64/arm64 darwin --- .cirrus.yml | 97 ------- .github/workflows/devel.yml | 227 +++++++++++++++ .github/workflows/release-beta.yml | 157 +++++++++++ .github/workflows/release.yml | 201 ++++++++++++++ Dockerfile | 292 -------------------- Makefile | 46 +-- Dockerfile.cross => docker/amd64/Dockerfile | 51 +++- docker/arm64/Dockerfile | 224 +++++++++++++++ 8 files changed, 861 insertions(+), 434 deletions(-) delete mode 100644 .cirrus.yml create mode 100644 .github/workflows/devel.yml create mode 100644 .github/workflows/release-beta.yml create mode 100644 .github/workflows/release.yml delete mode 100644 Dockerfile rename Dockerfile.cross => docker/amd64/Dockerfile (78%) create mode 100644 docker/arm64/Dockerfile diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index 54cf704..0000000 --- a/.cirrus.yml +++ /dev/null @@ -1,97 +0,0 @@ -task: - only_if: $CIRRUS_TAG == '' - timeout_in: 120m - matrix: - - name: linux-amd64 - compute_engine_instance: - image_project: cirrus-images - image: family/docker-builder - platform: linux - cpu: 8 - memory: 8G - - - name: linux-arm64 - compute_engine_instance: - image_project: cirrus-images - image: family/docker-builder-arm64 - architecture: arm64 - platform: linux - cpu: 4 - memory: 4G - - build_script: make build - run_script: make test - -task: - only_if: $CIRRUS_TAG != '' - alias: build-linux-image - timeout_in: 120m - env: - DOCKER_USERNAME: ENCRYPTED[db65fd6fc1af68040964a27c82f2cbd202c849199038cfddc961a573d803a4f2793ba30eede0b6bcdb6bbf29f5c4f012] - DOCKER_PASSWORD: ENCRYPTED[a1503baddfbe37c5a4474c46ec12b11beee3d16c054c1fa5bfcdde674be32524781f9d4e4d9444db6575fc5aa6270040] - matrix: - - name: linux-amd64 - env: - CIRRUS_ARCH: amd64 - compute_engine_instance: - image_project: cirrus-images - image: family/docker-builder - platform: linux - cpu: 8 - memory: 8G - - - name: linux-arm64 - env: - CIRRUS_ARCH: arm64 - compute_engine_instance: - image_project: cirrus-images - image: family/docker-builder-arm64 - architecture: arm64 - platform: linux - cpu: 4 - memory: 4G - - build_script: TAG=$CIRRUS_ARCH make build - login_script: docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD - push_script: docker push joseluisq/rust-linux-darwin-builder:$CIRRUS_ARCH - -release_docker_builder: - only_if: $CIRRUS_TAG != '' - depends_on: - - build-linux-image - env: - DOCKER_USERNAME: ENCRYPTED[db65fd6fc1af68040964a27c82f2cbd202c849199038cfddc961a573d803a4f2793ba30eede0b6bcdb6bbf29f5c4f012] - DOCKER_PASSWORD: ENCRYPTED[a1503baddfbe37c5a4474c46ec12b11beee3d16c054c1fa5bfcdde674be32524781f9d4e4d9444db6575fc5aa6270040] - login_script: | - docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD - push_latest_script: | - docker manifest create \ - joseluisq/rust-linux-darwin-builder:latest \ - --amend joseluisq/rust-linux-darwin-builder:amd64 \ - --amend joseluisq/rust-linux-darwin-builder:arm64 - docker manifest push joseluisq/rust-linux-darwin-builder:latest - pull_latest_script: | - docker pull joseluisq/rust-linux-darwin-builder:amd64 - docker pull joseluisq/rust-linux-darwin-builder:arm64 - push_aliases_script: | - SEMVER=${CIRRUS_TAG##*v} - SEMVER_MAJOR=${SEMVER%.*.*} - SEMVER_MINOR=${SEMVER%.*} - - docker manifest create \ - joseluisq/rust-linux-darwin-builder:${SEMVER} \ - --amend joseluisq/rust-linux-darwin-builder:amd64 \ - --amend joseluisq/rust-linux-darwin-builder:arm64 - docker manifest push joseluisq/rust-linux-darwin-builder:${SEMVER} - - docker manifest create \ - joseluisq/rust-linux-darwin-builder:${SEMVER_MAJOR} \ - --amend joseluisq/rust-linux-darwin-builder:amd64 \ - --amend joseluisq/rust-linux-darwin-builder:arm64 - docker manifest push joseluisq/rust-linux-darwin-builder:${SEMVER_MAJOR} - - docker manifest create \ - joseluisq/rust-linux-darwin-builder:${SEMVER_MINOR} \ - --amend joseluisq/rust-linux-darwin-builder:amd64 \ - --amend joseluisq/rust-linux-darwin-builder:arm64 - docker manifest push joseluisq/rust-linux-darwin-builder:${SEMVER_MINOR} diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml new file mode 100644 index 0000000..f1a7e13 --- /dev/null +++ b/.github/workflows/devel.yml @@ -0,0 +1,227 @@ +name: devel +on: + pull_request: + branches: + - master + paths: + - docker/** + - .github/workflows/*.yml + push: + branches: + - master + paths: + - docker/** + - .github/workflows/*.yml + +env: + DOCKER_IMAGE: localhost:5000/github.com/joseluisq/rust-linux-darwin-builder + +jobs: + docker-amd64: + name: Docker test (amd64) + runs-on: ubuntu-22.04 + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - + name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: rust-linux-darwin-builder-amd64-buildx-${{ github.sha }} + restore-keys: | + rust-linux-darwin-builder-amd64-buildx- + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + flavor: | + latest=false + suffix=-amd64 + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + - + name: Build and export to Docker client + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + file: docker/amd64/Dockerfile + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + - + name: Build and push to local registry + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + file: docker/amd64/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - + name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Check manifest + if: github.event_name != 'pull_request' + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Run tests + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + docker-arm64: + name: Docker test (arm64) + runs-on: ubuntu-22.04-arm + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - + name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: rust-linux-darwin-builder-arm64-buildx-${{ github.sha }} + restore-keys: | + rust-linux-darwin-builder-arm64-buildx- + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + flavor: | + latest=false + suffix=-arm64 + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + - + name: Build and export to Docker client + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/Dockerfile + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + - + name: Build and push to local registry + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - + name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Check manifest + if: github.event_name != 'pull_request' + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Run tests + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml new file mode 100644 index 0000000..80a6732 --- /dev/null +++ b/.github/workflows/release-beta.yml @@ -0,0 +1,157 @@ +name: release-beta +on: + push: + tags: + - 'v1.0.[0-9]+-beta.[0-9]+' + - 'v2.0.[0-9]+-beta.[0-9]+' + +jobs: + build-amd64: + name: osxcross (amd64) + runs-on: ubuntu-22.04 + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + joseluisq/rust-linux-darwin-builder + ghcr.io/joseluisq/rust-linux-darwin-builder + flavor: | + latest=false + suffix=-amd64 + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{version}}-amd64 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + provenance: false + context: . + platforms: linux/amd64 + file: ./docker/amd64/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + + build-arm64: + name: osxcross (arm64) + runs-on: ubuntu-22.04-arm + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + joseluisq/rust-linux-darwin-builder + ghcr.io/joseluisq/rust-linux-darwin-builder + flavor: | + latest=false + suffix=-arm64 + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{version}}-arm64 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + provenance: false + context: . + platforms: linux/arm64 + file: ./docker/arm64/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + + manifest: + needs: + - build-amd64 + - build-arm64 + runs-on: ubuntu-22.04 + steps: + - name: Set envs + run: | + github_ref=${GITHUB_REF#refs/tags/} + SEMVER=${github_ref##*v} + echo "SEMVER=${SEMVER}" >> $GITHUB_ENV + echo $SEMVER + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Pull all images + run: | + docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 + docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + - + name: Push semver alias + run: | + docker manifest create \ + joseluisq/rust-linux-darwin-builder:$SEMVER \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push joseluisq/rust-linux-darwin-builder:$SEMVER + + docker manifest create \ + ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c5694b3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,201 @@ +name: release +on: + push: + tags: + - 'v1.0.[0-9]+' + - 'v2.0.[0-9]+' + +jobs: + build-amd64: + name: osxcross (amd64) + runs-on: ubuntu-22.04 + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta-amd64 + uses: docker/metadata-action@v5 + with: + images: joseluisq/rust-linux-darwin-builder + flavor: | + latest=true + suffix=-amd64 + tags: | + type=semver,pattern={{version}} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + provenance: false + context: . + platforms: linux/amd64 + file: ./docker/amd64/Dockerfile + tags: ${{ steps.meta-amd64.outputs.tags }} + + build-arm64: + name: osxcross (arm64) + runs-on: ubuntu-22.04-arm + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta-arm64 + uses: docker/metadata-action@v5 + with: + images: | + joseluisq/rust-linux-darwin-builder + ghcr.io/joseluisq/rust-linux-darwin-builder + flavor: | + latest=true + suffix=-arm64 + tags: | + type=semver,pattern={{version}} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + provenance: false + context: . + platforms: linux/arm64 + file: ./docker/arm64/Dockerfile + tags: ${{ steps.meta-arm64.outputs.tags }} + + manifest: + needs: + - build-amd64 + - build-arm64 + runs-on: ubuntu-22.04 + steps: + - name: Set envs + run: | + github_ref=${GITHUB_REF#refs/tags/} + SEMVER=${github_ref##*v} + SEMVER_MAJOR=${SEMVER%.*.*} + SEMVER_MINOR=${SEMVER%.*} + echo "SEMVER=${SEMVER}" >> $GITHUB_ENV + echo "SEMVER_MAJOR=${SEMVER_MAJOR}" >> $GITHUB_ENV + echo "SEMVER_MINOR=${SEMVER_MINOR}" >> $GITHUB_ENV + echo $SEMVER + echo $SEMVER_MAJOR + echo $SEMVER_MINOR + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Pull all images + run: | + docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 + docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + - + name: Push semver minor alias + run: | + docker manifest create \ + joseluisq/rust-linux-darwin-builder:$SEMVER_MINOR \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push joseluisq/rust-linux-darwin-builder:$SEMVER_MINOR + + docker manifest create \ + ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER_MINOR \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER_MINOR + - + name: Push latest (1.0 or newer) + run: | + docker manifest create \ + joseluisq/rust-linux-darwin-builder:latest \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push joseluisq/rust-linux-darwin-builder:latest + + docker manifest create \ + ghcr.io/joseluisghcr.io/q/rust-linux-darwin-builder:latest \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:latest + - + name: Push semver alias + run: | + docker manifest create \ + joseluisq/rust-linux-darwin-builder:$SEMVER \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push joseluisq/rust-linux-darwin-builder:$SEMVER + + docker manifest create \ + ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER + - + name: Push semver major alias (1.0 or newer) + run: | + docker manifest create \ + joseluisq/rust-linux-darwin-builder:$SEMVER_MAJOR \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push joseluisq/rust-linux-darwin-builder:$SEMVER_MAJOR + + docker manifest create \ + ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER_MAJOR \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 + docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER_MAJOR diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 46121a5..0000000 --- a/Dockerfile +++ /dev/null @@ -1,292 +0,0 @@ -# NOTE: Most of Dockerfile and related were borrowed from https://hub.docker.com/r/ekidd/rust-musl-builder - -FROM debian:12.12-slim - -ARG VERSION=0.0.0 -ENV VERSION=${VERSION} - -LABEL version="${VERSION}" \ - description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ - maintainer="Jose Quintana " - -# Make sure we have basic dev tools for building C libraries. Our goal -# here is to support the musl-libc builds and Cargo builds needed for a -# large selection of the most popular crates. -RUN set -eux \ - && dpkg --add-architecture armhf \ - && dpkg --add-architecture arm64 \ - && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ - autoconf \ - automake \ - bison \ - build-essential \ - ca-certificates \ - clang \ - cmake \ - curl \ - file \ - flex \ - g++-aarch64-linux-gnu \ - gcc-aarch64-linux-gnu \ - gcc-arm-linux-gnueabihf \ - git \ - libbz2-dev \ - libgmp-dev \ - libicu-dev \ - libmpc-dev \ - libmpfr-dev \ - libpq-dev \ - libsqlite3-dev \ - libssl-dev \ - libtool \ - libxml2-dev \ - linux-libc-dev \ - llvm-dev \ - lzma-dev \ - musl-dev \ - musl-dev:arm64 \ - musl-dev:armhf \ - musl-tools \ - patch \ - pkgconf \ - python3 \ - xutils-dev \ - xz-utils \ - yasm \ - zlib1g-dev \ - # Clean up local repository of retrieved packages and remove the package lists - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - && true - -# Static linking for C++ code -RUN set -eux \ - && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ - # Create appropriate directories for current user - && mkdir -p /root/libs /root/src \ - && true - -# Set up our path with all our binary directories, including those for the -# musl-gcc toolchain and for our Rust toolchain. -ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - -# Set up a `git credentials` helper for using GH_USER and GH_TOKEN to access -# private repositories if desired. -COPY scripts/git-credential-ghtoken /usr/local/bin -RUN set -eux \ - && git config --global credential.https://github.com.helper ghtoken \ - && true - -# Build a static library version of OpenSSL using musl-libc. This is needed by -# the popular Rust `hyper` crate. - -# OpenSSL 1.1.1 - https://github.com/openssl/openssl/releases -ARG OPENSSL_VERSION=3.5.3 - -# We point /usr/local/musl/include/linux at some Linux kernel headers (not -# necessarily the right ones) in an effort to compile OpenSSL 1.1's "engine" -# component. It's possible that this will cause bizarre and terrible things to -# happen. There may be "sanitized" header -RUN set -eux \ - && dpkgArch="$(dpkg --print-architecture)" \ - && case "${dpkgArch##*-}" in \ - amd64) config='';; \ - arm64) config='-mno-outline-atomics';; \ - *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ - esac \ - && echo "Building OpenSSL ${OPENSSL_VERSION}..." \ - && ls /usr/include/linux \ - && mkdir -p /usr/local/musl/include \ - && ln -s /usr/include/linux /usr/local/musl/include/linux \ - && ln -s "/usr/include/$(uname -m)-linux-gnu/asm" /usr/local/musl/include/asm \ - && ln -s /usr/include/asm-generic /usr/local/musl/include/asm-generic \ - && cd /tmp \ - && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ - && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ - && cd "openssl-${OPENSSL_VERSION}" \ - && env CC=musl-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/musl -DOPENSSL_NO_SECURE_MEMORY ${config} "linux-$(uname -m)" \ - && env C_INCLUDE_PATH=/usr/local/musl/include/ make depend \ - && env C_INCLUDE_PATH=/usr/local/musl/include/ make -j$(nproc) \ - && make -j$(nproc) install_sw \ - && make -j$(nproc) install_ssldirs \ - && openssl version \ - && rm -rf \ - /usr/local/musl/include/linux \ - /usr/local/musl/include/asm \ - /usr/local/musl/include/asm-generic \ - && ls -l /usr/local/musl \ - && if [ "$(uname -m)" = "x86_64" ]; then \ - ln -s /usr/local/musl/lib64 /usr/local/musl/lib; \ - fi \ - && rm -r /tmp/* \ - && true - -RUN set -eux \ - && echo "Testing musl-gcc with OpenSSL..." \ - && openssl version \ - && echo "int main(){return 0;}" | \ - musl-gcc -o test -x c - \ - -I/usr/local/musl/include \ - -L/usr/local/musl/lib \ - -lssl -lcrypto \ - && true - -# zlib - http://zlib.net/ -ARG ZLIB_VERSION=1.3.1 - -RUN set -eux \ - && echo "Building zlib ${ZLIB_VERSION}..." \ - && cd /tmp \ - && curl -LO "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ - && tar xzf "zlib-${ZLIB_VERSION}.tar.gz" \ - && cd "zlib-${ZLIB_VERSION}" \ - && env CC=musl-gcc ./configure --static --prefix=/usr/local/musl \ - && make -j$(nproc) \ - && make -j$(nproc) install \ - && rm -r /tmp/* \ - && true - - -# libpq - https://ftp.postgresql.org/pub/source/ -ARG POSTGRESQL_VERSION=17.6 -ARG ICU4C_VERSION=77.1 - -RUN set -eux \ - && echo "Building icu4c..." \ - && cd /tmp \ - && ver1=$(echo $ICU4C_VERSION | sed -e 's:\.:-:g') \ - && ver2=$(echo $ICU4C_VERSION | sed -e 's:\.:_:g') \ - && curl -LO https://github.com/unicode-org/icu/releases/download/release-${ver1}/icu4c-${ver2}-src.tgz \ - && tar xf icu4c-${ver2}-src.tgz \ - && cd icu/source \ - && env CC=musl-gcc CXX=musl-g++ ./configure --prefix=/usr/local/musl \ - && make -j$(nproc) \ - && make -j$(nproc) install \ - && rm -r /tmp/* \ - && true - -RUN set -eux \ - && echo "Building libpq ${POSTGRESQL_VERSION}..." \ - && cd /tmp \ - && curl -LO "https://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.gz" \ - && tar xzf "postgresql-${POSTGRESQL_VERSION}.tar.gz" \ - && cd "postgresql-${POSTGRESQL_VERSION}" \ - && env CC=musl-gcc CPPFLAGS=-I/usr/local/musl/include LDFLAGS=-L/usr/local/musl/lib ./configure --with-openssl --without-readline --prefix=/usr/local/musl \ - && cd src/interfaces/libpq \ - && make -j$(nproc) all-static-lib \ - && make -j$(nproc) install-lib-static \ - && cd ../../bin/pg_config \ - && make -j$(nproc) \ - && make -j$(nproc) install \ - && rm -r /tmp/* \ - && true - -ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/musl/ \ - AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/musl/ \ - X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 \ - AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 \ - PQ_LIB_STATIC_X86_64_UNKNOWN_LINUX_MUSL=1 \ - PQ_LIB_STATIC_AARCH64_UNKNOWN_LINUX_MUSL=1 \ - PG_CONFIG_X86_64_UNKNOWN_LINUX_GNU=/usr/bin/pg_config \ - PG_CONFIG_AARCH64_UNKNOWN_LINUX_GNU=/usr/bin/pg_config \ - PKG_CONFIG_ALLOW_CROSS=true \ - PKG_CONFIG_ALL_STATIC=true \ - LIBZ_SYS_STATIC=1 \ - TARGET=musl - -# (Please feel free to submit pull requests for musl-libc builds of other C -# libraries needed by the most popular and common Rust crates, to avoid -# everybody needing to build them manually.) - - -# Mac OS X SDK version - https://github.com/joseluisq/macosx-sdks -ARG OSX_SDK_VERSION=13.3 -ARG OSX_SDK_SUM=518e35eae6039b3f64e8025f4525c1c43786cc5cf39459d609852faf091e34be -ARG OSX_VERSION_MIN=10.14 - -# OS X Cross - https://github.com/tpoechtrager/osxcross -ARG OSX_CROSS_COMMIT=f873f534c6cdb0776e457af8c7513da1e02abe59 - -# Install OS X Cross -# A Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android -RUN set -eux \ - && echo "Cloning osxcross..." \ - && git clone https://github.com/tpoechtrager/osxcross.git /usr/local/osxcross \ - && cd /usr/local/osxcross \ - && git checkout -q "${OSX_CROSS_COMMIT}" \ - && rm -rf ./.git \ - && true - -RUN set -eux \ - && echo "Building osxcross with ${OSX_SDK_VERSION}..." \ - && cd /usr/local/osxcross \ - && curl -Lo "./tarballs/MacOSX${OSX_SDK_VERSION}.sdk.tar.xz" \ - "https://github.com/joseluisq/macosx-sdks/releases/download/${OSX_SDK_VERSION}/MacOSX${OSX_SDK_VERSION}.sdk.tar.xz" \ - && echo "${OSX_SDK_SUM} ./tarballs/MacOSX${OSX_SDK_VERSION}.sdk.tar.xz" \ - | sha256sum -c - \ - && env UNATTENDED=yes OSX_VERSION_MIN=${OSX_VERSION_MIN} ./build.sh \ - && true - -RUN set -eux \ - && cd /usr/local/osxcross \ - && echo "Building osxcross with compiler-rt..." \ - # compiler-rt can be needed to build code using `__builtin_available()` - && env DISABLE_PARALLEL_ARCH_BUILD=1 ./build_compiler_rt.sh \ - && true - -ENV PATH=$PATH:/usr/local/osxcross/target/bin -ENV MACOSX_DEPLOYMENT_TARGET=${OSX_VERSION_MIN} -ENV OSXCROSS_MACPORTS_MIRROR=https://packages.macports.org -ENV OSXCROSS_MACPORTS_LOCAL=/usr/local/osxcross/target/macports/pkgs/opt/local -ENV OSXCROSS_MACPORTS_LIBEXEC=${OSXCROSS_MACPORTS_LOCAL}/libexec - -RUN set -eux \ - && echo "Testing osxcross with compiler-rt..." \ - && echo "int main(void){return 0;}" | xcrun clang -xc -o/dev/null -v - 2>&1 | grep "libclang_rt" 1>/dev/null \ - && echo "compiler-rt installed and working successfully!" \ - && true - -RUN set -eux \ - && echo "Install dependencies via osxcross tools..." \ - && apt-get update \ - && /usr/local/osxcross/tools/get_dependencies.sh \ - && osxcross-macports install zlib openssl3 \ - && true - -# Rust stable toolchain -ARG TOOLCHAIN=1.87.0 - -# Install our Rust toolchain and the `musl` target. We patch the -# command-line we pass to the installer so that it won't attempt to -# interact with the user or fool around with TTYs. We also set the default -# `--target` to musl so that our users don't need to keep overriding it manually. -RUN set -eux \ - && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ - && rustup target add \ - aarch64-apple-darwin \ - aarch64-unknown-linux-gnu \ - aarch64-unknown-linux-musl \ - armv7-unknown-linux-musleabihf \ - x86_64-apple-darwin \ - x86_64-unknown-linux-musl \ - && true -COPY cargo/config.toml /root/.cargo/config.toml - -RUN set -eux \ - && echo "Removing temp files..." \ - && rm -rf *~ taballs *.tar.xz \ - && rm -rf /tmp/* \ - && true - -WORKDIR /root/src - -CMD ["bash"] - -# Metadata -LABEL org.opencontainers.image.vendor="Jose Quintana" \ - org.opencontainers.image.url="https://github.com/joseluisq/rust-linux-darwin-builder" \ - org.opencontainers.image.title="Rust Linux / Darwin Builder" \ - org.opencontainers.image.description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ - org.opencontainers.image.version="$VERSION" \ - org.opencontainers.image.documentation="https://github.com/joseluisq/rust-linux-darwin-builder" diff --git a/Makefile b/Makefile index 31a6919..1aa8b51 100644 --- a/Makefile +++ b/Makefile @@ -9,29 +9,6 @@ build: -f Dockerfile . .PHONY: build -build-osxcross: - docker build \ - -t $(REPOSITORY)/rust-linux-darwin-builder:osxcross \ - --network=host \ - -f Dockerfile . -.PHONY: build-osxcross - -build-cross: - docker build \ - -t $(REPOSITORY)/rust-linux-darwin-builder:cross \ - --network=host \ - -f Dockerfile.cross . -.PHONY: build-cross - -run-cross: - @docker run --rm -it \ - -v $(PWD):/root/src \ - -v $(PWD)/cargo/config.toml:/root/.cargo/config.toml \ - -w /root/src \ - $(REPOSITORY)/rust-linux-darwin-builder:cross \ - bash -.PHONY: run-cross - # Use to build both arm64 and amd64 images at the same time. # WARNING! Will automatically push, since multi-platform images are not available locally. # Use `REPOSITORY` arg to specify which container repository to push the images to. @@ -50,6 +27,7 @@ buildx: run: @docker run --rm -it \ -v $(PWD):/root/src \ + -v $(PWD)/cargo/config.toml:/root/.cargo/config.toml \ -w /root/src \ $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ bash @@ -60,10 +38,10 @@ test: -v $(PWD):/root/src \ -w /root/src \ $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ - bash -c 'set -eu; make test-ci; make test-openssl' + bash -c 'set -eu; make test-app; make test-zlib; make test-openssl' .PHONY: test -test-ci: +test-app: @echo "Checking Debian version..." @cat /etc/debian_version @echo @@ -116,7 +94,7 @@ test-ci: && cargo build --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/hello-world-test \ && file target/aarch64-apple-darwin/release/hello-world-test -.ONESHELL: test-ci +.ONESHELL: test-app test-zlib: @echo "Checking Debian version..." @@ -193,7 +171,8 @@ test-openssl: echo; \ \ echo "Compiling application (linux-musl x86_64)..."; \ - cargo build --release --target x86_64-unknown-linux-musl; \ + OPENSSL_STATIC=1 \ + cargo build --release --target x86_64-unknown-linux-musl; \ target/x86_64-unknown-linux-musl/release/openssl; \ du -sh target/x86_64-unknown-linux-musl/release/openssl; \ file target/x86_64-unknown-linux-musl/release/openssl; \ @@ -209,22 +188,17 @@ test-openssl: && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ - && cargo build --release --target aarch64-unknown-linux-musl \ - && if [ "$$(uname -m)" = "arm64" ]; then \ - target/aarch64-unknown-linux-musl/release/openssl; \ - fi \ + && OPENSSL_STATIC=1 \ + cargo build --release --target aarch64-unknown-linux-musl \ && du -sh target/aarch64-unknown-linux-musl/release/openssl \ && file target/aarch64-unknown-linux-musl/release/openssl \ && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ - && CC=oa64-clang CXX=oa64-clang++ \ + && OPENSSL_STATIC=1 \ + CC=oa64-clang CXX=oa64-clang++ \ cargo build --release --target aarch64-apple-darwin \ - && if [ "$$(uname -m)" = "arm64" ]; then \ - target/aarch64-apple-darwin/release/openssl; \ - fi \ && du -sh target/aarch64-apple-darwin/release/openssl \ && file target/aarch64-apple-darwin/release/openssl \ && echo \ - && echo "Cross-compiling done." .ONESHELL: test-openssl diff --git a/Dockerfile.cross b/docker/amd64/Dockerfile similarity index 78% rename from Dockerfile.cross rename to docker/amd64/Dockerfile index ac7392f..dabe150 100644 --- a/Dockerfile.cross +++ b/docker/amd64/Dockerfile @@ -93,10 +93,6 @@ RUN set -eux \ && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ && true -# We point /usr/local/musl/include/linux at some Linux kernel headers (not -# necessarily the right ones) in an effort to compile OpenSSL 1.1's "engine" -# component. It's possible that this will cause bizarre and terrible things to -# happen. There may be "sanitized" header RUN set -eux \ && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ && cd "openssl-${OPENSSL_VERSION}" \ @@ -138,9 +134,6 @@ RUN set -eux \ && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64..." \ && ls /usr/include/linux \ && mkdir -p /usr/local/aarch64-linux-gnu/include \ - # && ln -s /usr/include/linux /usr/local/aarch64-linux-gnu/include/linux \ - # && ln -s "/usr/include/aarch64-linux-gnu/asm" /usr/local/aarch64-linux-gnu/include/asm \ - # && ln -s /usr/include/asm-generic /usr/local/aarch64-linux-gnu/include/asm-generic \ && env CC=aarch64-linux-gnu-gcc ./Configure no-shared no-zlib \ -fPIC --prefix=/usr/local/aarch64-linux-gnu \ -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ @@ -158,6 +151,44 @@ RUN set -eux \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for MACOS aarch64..." \ + && mkdir -p /usr/local/aarch64-apple-darwin/include \ + && env CC=oa64-clang \ + ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/aarch64-apple-darwin \ + -DOPENSSL_NO_SECURE_MEMORY "darwin64-arm64-cc" \ + && make -j$(nproc) build_libs \ + && make -j$(nproc) install_dev \ + && rm -rf \ + /usr/local/aarch64-apple-darwin/include/asm \ + /usr/local/aarch64-apple-darwin/include/asm-generic \ + && ls -l /usr/local/aarch64-apple-darwin \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for MACOS x86_64..." \ + && mkdir -p /usr/local/x86_64-apple-darwin/include \ + && env CC=o64-clang \ + ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/x86_64-apple-darwin \ + -DOPENSSL_NO_SECURE_MEMORY "darwin64-x86_64-cc" \ + && make -j$(nproc) build_libs \ + && make -j$(nproc) install_dev \ + && rm -rf \ + /usr/local/x86_64-apple-darwin/include/asm \ + /usr/local/x86_64-apple-darwin/include/asm-generic \ + && ls -l /usr/local/x86_64-apple-darwin \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + RUN set -eux \ && echo "Testing musl-gcc with OpenSSL..." \ && openssl version \ @@ -171,10 +202,12 @@ RUN set -eux \ WORKDIR /root # OpenSSL related environment variables -ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl -ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 +ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl +ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu +ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin # pkg-config related environment variables ENV PKG_CONFIG_ALLOW_CROSS=true \ diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile new file mode 100644 index 0000000..dabe150 --- /dev/null +++ b/docker/arm64/Dockerfile @@ -0,0 +1,224 @@ +FROM joseluisq/docker-osxcross:1.0.0-beta.1 + +ARG VERSION=0.0.0 +ENV VERSION=${VERSION} + +LABEL version="${VERSION}" \ + description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + +# Static linking for C++ code +RUN set -eux \ + && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ + # Create appropriate directories for current user + && mkdir -p /root/libs /root/src \ + && true + +ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH + +##### Rust toolchains + +# Rust/Cargo related environment variables +ENV TARGET=musl +# Crate-related environment variables +ENV LIBZ_SYS_STATIC=1 + +# Rust stable toolchain +ARG TOOLCHAIN=1.87.0 + +RUN set -eux \ + && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ + && rustup target add \ + aarch64-apple-darwin \ + aarch64-unknown-linux-gnu \ + aarch64-unknown-linux-musl \ + x86_64-apple-darwin \ + x86_64-unknown-linux-musl \ + && true + +COPY cargo/config.toml /root/.cargo/config.toml + +RUN set -eux \ + && rustc -vV \ + && cargo -vV \ + && true + +##### Libraries + +# zlib - http://zlib.net/ +ARG ZLIB_VERSION=1.3.1 + +WORKDIR /tmp + +RUN set -eux \ + && echo "Downloading zlib ${ZLIB_VERSION}..." \ + && cd /tmp \ + && curl -LO "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ + && tar xzf "zlib-${ZLIB_VERSION}.tar.gz" \ + && rm -rf "zlib-${ZLIB_VERSION}.tar.gz" \ + && true + +WORKDIR /tmp/zlib-${ZLIB_VERSION} + +# x86_64 glibc +RUN set -eux \ + && make distclean \ + && CC=gcc ./configure --prefix=/usr/local/x86_64-linux-gnu \ + && make -j$(nproc) \ + && make install \ + && true + +# arm64 glibc +RUN set -eux \ + && make distclean \ + && CC=aarch64-linux-gnu-gcc ./configure --prefix=/usr/local/aarch64-linux-gnu \ + && make -j$(nproc) \ + && make install \ + && true + +# x86_64 musl +RUN set -eux \ + && make distclean \ + && CC=musl-gcc ./configure --static --prefix=/usr/local/x86_64-linux-musl \ + && make -j$(nproc) \ + && make install \ + && true + +WORKDIR /tmp + +# OpenSSL 3.5.3 - https://github.com/openssl/openssl/releases +ARG OPENSSL_VERSION=3.5.3 + +RUN set -eux \ + && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ + && true + +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \ + && ls /usr/include/linux \ + && mkdir -p /usr/local/x86_64-linux-musl/include \ + && ln -s /usr/include/linux /usr/local/x86_64-linux-musl/include/linux \ + && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ + && ln -s /usr/include/asm-generic /usr/local/x86_64-linux-musl/include/asm-generic \ + && env CC=musl-gcc ./Configure no-shared no-zlib \ + -fPIC --prefix=/usr/local/x86_64-linux-musl \ + -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ + && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && openssl version \ + && rm -rf \ + /usr/local/x86_64-linux-musl/include/linux \ + /usr/local/x86_64-linux-musl/include/asm \ + /usr/local/x86_64-linux-musl/include/asm-generic \ + && ls -l /usr/local/x86_64-linux-musl \ + && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \ + ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ + else \ + mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \ + mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ + cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \ + unlink /usr/local/x86_64-linux-musl/lib/lib64; \ + rm -rf /usr/local/x86_64-linux-musl/abc; \ + fi \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64..." \ + && ls /usr/include/linux \ + && mkdir -p /usr/local/aarch64-linux-gnu/include \ + && env CC=aarch64-linux-gnu-gcc ./Configure no-shared no-zlib \ + -fPIC --prefix=/usr/local/aarch64-linux-gnu \ + -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && openssl version \ + && rm -rf \ + /usr/local/aarch64-linux-gnu/include/linux \ + /usr/local/aarch64-linux-gnu/include/asm \ + /usr/local/aarch64-linux-gnu/include/asm-generic \ + && ls -l /usr/local/aarch64-linux-gnu \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for MACOS aarch64..." \ + && mkdir -p /usr/local/aarch64-apple-darwin/include \ + && env CC=oa64-clang \ + ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/aarch64-apple-darwin \ + -DOPENSSL_NO_SECURE_MEMORY "darwin64-arm64-cc" \ + && make -j$(nproc) build_libs \ + && make -j$(nproc) install_dev \ + && rm -rf \ + /usr/local/aarch64-apple-darwin/include/asm \ + /usr/local/aarch64-apple-darwin/include/asm-generic \ + && ls -l /usr/local/aarch64-apple-darwin \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for MACOS x86_64..." \ + && mkdir -p /usr/local/x86_64-apple-darwin/include \ + && env CC=o64-clang \ + ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/x86_64-apple-darwin \ + -DOPENSSL_NO_SECURE_MEMORY "darwin64-x86_64-cc" \ + && make -j$(nproc) build_libs \ + && make -j$(nproc) install_dev \ + && rm -rf \ + /usr/local/x86_64-apple-darwin/include/asm \ + /usr/local/x86_64-apple-darwin/include/asm-generic \ + && ls -l /usr/local/x86_64-apple-darwin \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + +RUN set -eux \ + && echo "Testing musl-gcc with OpenSSL..." \ + && openssl version \ + && echo "int main(){return 0;}" | \ + musl-gcc -o test -x c - \ + -I/usr/local/x86_64-linux-musl/include \ + -L/usr/local/x86_64-linux-musl/lib \ + -lssl -lcrypto \ + && true + +WORKDIR /root + +# OpenSSL related environment variables +ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 +ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl +ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu +ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin + +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=true \ + PKG_CONFIG_ALL_STATIC=true + +RUN set -eux \ + && echo "Removing temp files..." \ + && rm -rf *~ taballs *.tar.xz \ + && rm -rf /tmp/* \ + && true + +WORKDIR /root/src + +CMD ["bash"] From 78b870326649c20c893992032f764c38d164796e Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 3 Oct 2025 23:29:56 +0200 Subject: [PATCH 03/19] chore: update joseluisq/docker-osxcross to 1.0.0-beta.2 --- Makefile | 99 +++++++++++++++++++++++++---------------- docker/amd64/Dockerfile | 86 ++++++++++++++++++++++++++--------- docker/arm64/Dockerfile | 87 +++++++++++++++++++++++++++--------- 3 files changed, 194 insertions(+), 78 deletions(-) diff --git a/Makefile b/Makefile index 1aa8b51..2467014 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ build: docker build \ -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ --network=host \ - -f Dockerfile . + -f docker/amd64/Dockerfile . .PHONY: build # Use to build both arm64 and amd64 images at the same time. @@ -50,21 +50,23 @@ test-app: @echo @cd tests/hello-world \ \ + && echo "Compiling application (linux-gnu x86_64)..." \ + && cargo build --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then \ - echo "Compiling application (linux-gnu x86_64)..."; \ - cargo build --release --target x86_64-unknown-linux-gnu; \ target/x86_64-unknown-linux-gnu/release/hello-world-test; \ - du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test; \ - file target/x86_64-unknown-linux-gnu/release/hello-world-test; \ - echo; \ + fi \ + && du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test \ + && file target/x86_64-unknown-linux-gnu/release/hello-world-test \ + && echo \ \ - echo "Compiling application (linux-musl x86_64)..."; \ - cargo build --release --target x86_64-unknown-linux-musl; \ + && echo "Compiling application (linux-musl x86_64)..." \ + && cargo build --release --target x86_64-unknown-linux-musl \ + && if [ "$$(uname -m)" = "x86_64" ]; then \ target/x86_64-unknown-linux-musl/release/hello-world-test; \ - du -sh target/x86_64-unknown-linux-musl/release/hello-world-test; \ - file target/x86_64-unknown-linux-musl/release/hello-world-test; \ - echo; \ fi \ + && du -sh target/x86_64-unknown-linux-musl/release/hello-world-test \ + && file target/x86_64-unknown-linux-musl/release/hello-world-test \ + && echo \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ && cargo build --release --target x86_64-apple-darwin \ @@ -94,6 +96,7 @@ test-app: && cargo build --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/hello-world-test \ && file target/aarch64-apple-darwin/release/hello-world-test + && echo .ONESHELL: test-app test-zlib: @@ -105,30 +108,34 @@ test-zlib: @echo @cd tests/zlib \ \ - && if [ "$$(uname -m)" = "x86_64" ]; then \ - echo "Compiling application (linux-gnu x86_64)..."; \ - cargo build --release --target x86_64-unknown-linux-gnu; \ + && echo "Compiling application (linux-gnu x86_64)..." \ + && cargo build --release --target x86_64-unknown-linux-gnu \ + && if [ "$$(uname -m)" = "x86_64" ]; then target/x86_64-unknown-linux-gnu/release/zlib-test; \ - du -sh target/x86_64-unknown-linux-gnu/release/zlib-test; \ - file target/x86_64-unknown-linux-gnu/release/zlib-test; \ - echo; \ + fi \ + && du -sh target/x86_64-unknown-linux-gnu/release/zlib-test \ + && file target/x86_64-unknown-linux-gnu/release/zlib-test \ + && echo \ \ - echo "Compiling application (linux-musl x86_64)..."; \ - cargo build --release --target x86_64-unknown-linux-musl; \ + && echo "Compiling application (linux-musl x86_64)..." \ + && cargo build --release --target x86_64-unknown-linux-musl \ + && if [ "$$(uname -m)" = "x86_64" ]; then target/x86_64-unknown-linux-musl/release/zlib-test; \ - du -sh target/x86_64-unknown-linux-musl/release/zlib-test; \ - file target/x86_64-unknown-linux-musl/release/zlib-test; \ - echo; \ fi \ + && du -sh target/x86_64-unknown-linux-musl/release/zlib-test \ + && file target/x86_64-unknown-linux-musl/release/zlib-test \ + && echo \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ - && LIBZ_SYS_STATIC=1 CC=o64-clang CXX=o64-clang++ \ + && CC=o64-clang CXX=o64-clang++ \ cargo build --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/zlib-test \ && file target/x86_64-apple-darwin/release/zlib-test \ + && echo \ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ - && CC=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu \ + && CC=aarch64-linux-gnu-gcc \ + cargo build --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-gnu/release/zlib-test; \ fi \ @@ -146,7 +153,7 @@ test-zlib: && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ - && LIBZ_SYS_STATIC=1 CC=oa64-clang CXX=oa64-clang++ \ + && CC=oa64-clang CXX=oa64-clang++ \ cargo build --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/zlib-test \ && file target/aarch64-apple-darwin/release/zlib-test @@ -162,27 +169,39 @@ test-openssl: @echo @cd tests/openssl \ \ + && echo "Compiling application (linux-gnu x86_64)..." \ + && cargo build --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then \ - echo "Compiling application (linux-gnu x86_64)..."; \ - cargo build --release --target x86_64-unknown-linux-gnu; \ target/x86_64-unknown-linux-gnu/release/openssl; \ - du -sh target/x86_64-unknown-linux-gnu/release/openssl; \ - file target/x86_64-unknown-linux-gnu/release/openssl; \ - echo; \ + fi \ + && du -sh target/x86_64-unknown-linux-gnu/release/openssl \ + && file target/x86_64-unknown-linux-gnu/release/openssl \ + && echo \ \ - echo "Compiling application (linux-musl x86_64)..."; \ - OPENSSL_STATIC=1 \ - cargo build --release --target x86_64-unknown-linux-musl; \ + && echo "Cross-compiling application (linux-gnu aarch64)..." \ + && CC=aarch64-linux-gnu-gcc \ + cargo build --release --target aarch64-unknown-linux-gnu \ + && if [ "$$(uname -m)" = "aarch64" ]; then \ + target/aarch64-unknown-linux-gnu/release/openssl; \ + fi \ + && du -sh target/aarch64-unknown-linux-gnu/release/openssl \ + && file target/aarch64-unknown-linux-gnu/release/openssl \ + && echo \ +\ + && echo "Compiling application (linux-musl x86_64)..." \ + && OPENSSL_STATIC=1 \ + cargo build --release --target x86_64-unknown-linux-musl \ + && if [ "$$(uname -m)" = "x86_64" ]; then \ target/x86_64-unknown-linux-musl/release/openssl; \ - du -sh target/x86_64-unknown-linux-musl/release/openssl; \ - file target/x86_64-unknown-linux-musl/release/openssl; \ - echo; \ fi \ + && du -sh target/x86_64-unknown-linux-musl/release/openssl \ + && file target/x86_64-unknown-linux-musl/release/openssl \ + && echo \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ && OPENSSL_STATIC=1 \ CC=o64-clang CXX=o64-clang++ \ - cargo build --release --target x86_64-apple-darwin \ + cargo build --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/openssl \ && file target/x86_64-apple-darwin/release/openssl \ && echo \ @@ -190,6 +209,9 @@ test-openssl: && echo "Cross-compiling application (linux-musl aarch64)..." \ && OPENSSL_STATIC=1 \ cargo build --release --target aarch64-unknown-linux-musl \ + && if [ "$$(uname -m)" = "aarch64" ]; then \ + target/aarch64-unknown-linux-musl/release/openssl; + fi \ && du -sh target/aarch64-unknown-linux-musl/release/openssl \ && file target/aarch64-unknown-linux-musl/release/openssl \ && echo \ @@ -200,5 +222,6 @@ test-openssl: cargo build --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/openssl \ && file target/aarch64-apple-darwin/release/openssl \ - && echo \ + && echo + .ONESHELL: test-openssl diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile index dabe150..6f7e979 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/Dockerfile @@ -1,4 +1,4 @@ -FROM joseluisq/docker-osxcross:1.0.0-beta.1 +FROM joseluisq/docker-osxcross:1.0.0-beta.2 ARG VERSION=0.0.0 ENV VERSION=${VERSION} @@ -45,6 +45,23 @@ RUN set -eux \ ##### Libraries +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=true +ENV PKG_CONFIG_ALL_STATIC=true + +RUN set -eux \ + && dpkg --add-architecture arm64 \ + && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ + musl-dev \ + musl-dev:arm64 \ + musl-tools \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && true + # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 @@ -52,42 +69,52 @@ WORKDIR /tmp RUN set -eux \ && echo "Downloading zlib ${ZLIB_VERSION}..." \ - && cd /tmp \ - && curl -LO "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ - && tar xzf "zlib-${ZLIB_VERSION}.tar.gz" \ - && rm -rf "zlib-${ZLIB_VERSION}.tar.gz" \ + && curl -Lo zlib.tar.gz "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ && true -WORKDIR /tmp/zlib-${ZLIB_VERSION} - # x86_64 glibc RUN set -eux \ + && mkdir zlib \ + && tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \ + && cd zlib \ && make distclean \ && CC=gcc ./configure --prefix=/usr/local/x86_64-linux-gnu \ && make -j$(nproc) \ && make install \ + && cd .. \ + && rm -rf zlib \ && true # arm64 glibc RUN set -eux \ + && mkdir zlib \ + && tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \ + && cd zlib \ && make distclean \ && CC=aarch64-linux-gnu-gcc ./configure --prefix=/usr/local/aarch64-linux-gnu \ && make -j$(nproc) \ && make install \ + && cd .. \ + && rm -rf zlib \ && true # x86_64 musl RUN set -eux \ + && mkdir zlib \ + && tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \ + && cd zlib \ && make distclean \ && CC=musl-gcc ./configure --static --prefix=/usr/local/x86_64-linux-musl \ && make -j$(nproc) \ && make install \ + && cd .. \ + && rm -rf zlib zlib.tar.gz \ && true WORKDIR /tmp -# OpenSSL 3.5.3 - https://github.com/openssl/openssl/releases -ARG OPENSSL_VERSION=3.5.3 +# OpenSSL v3 - https://github.com/openssl/openssl/releases +ARG OPENSSL_VERSION=3.5.4 RUN set -eux \ && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ @@ -189,6 +216,27 @@ RUN set -eux \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64 musl..." \ + && mkdir -p /usr/local/aarch64-linux-musl/include \ + && env CC=aarch64-linux-musl-gcc \ + ./Configure no-asm no-engine no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/aarch64-linux-musl \ + -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && rm -rf \ + /usr/local/aarch64-linux-musl/include/asm \ + /usr/local/aarch64-linux-musl/include/asm-generic \ + && ls -l /usr/local/aarch64-linux-musl \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + RUN set -eux \ && echo "Testing musl-gcc with OpenSSL..." \ && openssl version \ @@ -199,26 +247,24 @@ RUN set -eux \ -lssl -lcrypto \ && true +RUN set -eux \ + && echo "Removing temp files..." \ + && rm -rf *~ taballs *.tar.xz \ + && rm -rf /tmp/* \ + && true + WORKDIR /root # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin + ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 -ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-musl +ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-gnu ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin -# pkg-config related environment variables -ENV PKG_CONFIG_ALLOW_CROSS=true \ - PKG_CONFIG_ALL_STATIC=true - -RUN set -eux \ - && echo "Removing temp files..." \ - && rm -rf *~ taballs *.tar.xz \ - && rm -rf /tmp/* \ - && true - WORKDIR /root/src CMD ["bash"] diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index dabe150..6ac3c4e 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -1,4 +1,4 @@ -FROM joseluisq/docker-osxcross:1.0.0-beta.1 +FROM joseluisq/docker-osxcross:1.0.0-beta.2 ARG VERSION=0.0.0 ENV VERSION=${VERSION} @@ -45,6 +45,23 @@ RUN set -eux \ ##### Libraries +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=true +ENV PKG_CONFIG_ALL_STATIC=true + +RUN set -eux \ + && dpkg --add-architecture amd64 \ + && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ + musl-dev \ + musl-dev:amd64 \ + musl-tools \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && true + # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 @@ -52,42 +69,52 @@ WORKDIR /tmp RUN set -eux \ && echo "Downloading zlib ${ZLIB_VERSION}..." \ - && cd /tmp \ - && curl -LO "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ - && tar xzf "zlib-${ZLIB_VERSION}.tar.gz" \ - && rm -rf "zlib-${ZLIB_VERSION}.tar.gz" \ + && curl -Lo zlib.tar.gz "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ && true -WORKDIR /tmp/zlib-${ZLIB_VERSION} - # x86_64 glibc RUN set -eux \ + && mkdir zlib \ + && tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \ + && cd zlib \ && make distclean \ && CC=gcc ./configure --prefix=/usr/local/x86_64-linux-gnu \ && make -j$(nproc) \ && make install \ + && cd .. \ + && rm -rf zlib \ && true # arm64 glibc RUN set -eux \ + && mkdir zlib \ + && tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \ + && cd zlib \ && make distclean \ && CC=aarch64-linux-gnu-gcc ./configure --prefix=/usr/local/aarch64-linux-gnu \ && make -j$(nproc) \ && make install \ + && cd .. \ + && rm -rf zlib \ && true # x86_64 musl RUN set -eux \ + && mkdir zlib \ + && tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \ + && cd zlib \ && make distclean \ && CC=musl-gcc ./configure --static --prefix=/usr/local/x86_64-linux-musl \ && make -j$(nproc) \ && make install \ + && cd .. \ + && rm -rf zlib zlib.tar.gz \ && true WORKDIR /tmp -# OpenSSL 3.5.3 - https://github.com/openssl/openssl/releases -ARG OPENSSL_VERSION=3.5.3 +# OpenSSL v3 - https://github.com/openssl/openssl/releases +ARG OPENSSL_VERSION=3.5.4 RUN set -eux \ && curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ @@ -189,6 +216,27 @@ RUN set -eux \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64 musl..." \ + && mkdir -p /usr/local/aarch64-linux-musl/include \ + && env CC=aarch64-linux-musl-gcc \ + ./Configure no-asm no-engine no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/aarch64-linux-musl \ + -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && rm -rf \ + /usr/local/aarch64-linux-musl/include/asm \ + /usr/local/aarch64-linux-musl/include/asm-generic \ + && ls -l /usr/local/aarch64-linux-musl \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true + RUN set -eux \ && echo "Testing musl-gcc with OpenSSL..." \ && openssl version \ @@ -199,26 +247,25 @@ RUN set -eux \ -lssl -lcrypto \ && true +RUN set -eux \ + && echo "Removing temp files..." \ + && rm -rf *~ taballs *.tar.xz \ + && rm -rf /tmp/* \ + && true + WORKDIR /root # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl +ENV X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/x86_64-linux-musl ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin + ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 -ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu +ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-musl +ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-gnu ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin -# pkg-config related environment variables -ENV PKG_CONFIG_ALLOW_CROSS=true \ - PKG_CONFIG_ALL_STATIC=true - -RUN set -eux \ - && echo "Removing temp files..." \ - && rm -rf *~ taballs *.tar.xz \ - && rm -rf /tmp/* \ - && true - WORKDIR /root/src CMD ["bash"] From e92a547d40954fc10e44d1f2d8dedc40c25333e8 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Sat, 4 Oct 2025 00:02:40 +0200 Subject: [PATCH 04/19] chore: add project dir for tests --- .github/workflows/devel.yml | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index f1a7e13..017d766 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -76,18 +76,6 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 - - - name: Build and push to local registry - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64 - file: docker/amd64/Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=0.0.0 cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - @@ -105,6 +93,7 @@ jobs: with: image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" shell: bash + options: -v ${{ github.workspace }}:/root/src run: | set -eux cat /etc/debian_version @@ -180,21 +169,8 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 - - - name: Build and push to local registry - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - file: docker/arm64/Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=0.0.0 cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - name: Inspect image run: | @@ -210,6 +186,7 @@ jobs: with: image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" shell: bash + options: -v ${{ github.workspace }}:/root/src run: | set -eux cat /etc/debian_version From 50c1a83ea90bfb96f203890b613eae3b47bddc6a Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Sat, 4 Oct 2025 12:07:03 +0200 Subject: [PATCH 05/19] fix: makefile test tasks and arm64 dockerfle --- Makefile | 19 +++++-- docker/arm64/Dockerfile | 115 +++++++++++++++++++--------------------- 2 files changed, 70 insertions(+), 64 deletions(-) diff --git a/Makefile b/Makefile index 2467014..2f40d15 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,20 @@ REPOSITORY ?= joseluisq TAG ?= latest -build: +build-amd64: docker build \ - -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ + -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \ --network=host \ -f docker/amd64/Dockerfile . -.PHONY: build +.PHONY: build-amd64 + +build-arm64: + docker buildx build \ + -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \ + --network=host \ + --platform linux/arm64 \ + -f docker/arm64/Dockerfile . +.PHONY: build-arm64 # Use to build both arm64 and amd64 images at the same time. # WARNING! Will automatically push, since multi-platform images are not available locally. @@ -95,7 +103,7 @@ test-app: && echo "Cross-compiling application (apple-darwin aarch64)..." \ && cargo build --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/hello-world-test \ - && file target/aarch64-apple-darwin/release/hello-world-test + && file target/aarch64-apple-darwin/release/hello-world-test \ && echo .ONESHELL: test-app @@ -156,7 +164,8 @@ test-zlib: && CC=oa64-clang CXX=oa64-clang++ \ cargo build --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/zlib-test \ - && file target/aarch64-apple-darwin/release/zlib-test + && file target/aarch64-apple-darwin/release/zlib-test \ + && echo \ .ONESHELL: test-zlib diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index 6ac3c4e..13bb436 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -56,8 +56,8 @@ RUN set -eux \ musl-dev \ musl-dev:amd64 \ musl-tools \ - gcc-aarch64-linux-gnu \ - g++-aarch64-linux-gnu \ + gcc-x86-64-linux-gnu \ + g++-x86-64-linux-gnu \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && true @@ -123,34 +123,23 @@ RUN set -eux \ RUN set -eux \ && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ && cd "openssl-${OPENSSL_VERSION}" \ - && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64..." \ && ls /usr/include/linux \ - && mkdir -p /usr/local/x86_64-linux-musl/include \ - && ln -s /usr/include/linux /usr/local/x86_64-linux-musl/include/linux \ - && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ - && ln -s /usr/include/asm-generic /usr/local/x86_64-linux-musl/include/asm-generic \ - && env CC=musl-gcc ./Configure no-shared no-zlib \ - -fPIC --prefix=/usr/local/x86_64-linux-musl \ - -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ - && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ - && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \ + && mkdir -p /usr/local/aarch64-linux-gnu/include \ + && env CC=aarch64-linux-gnu-gcc \ + ./Configure no-shared no-zlib \ + -fPIC --prefix=/usr/local/aarch64-linux-gnu \ + -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make -j$(nproc) \ && make -j$(nproc) install_sw \ && make -j$(nproc) install_ssldirs \ && openssl version \ && rm -rf \ - /usr/local/x86_64-linux-musl/include/linux \ - /usr/local/x86_64-linux-musl/include/asm \ - /usr/local/x86_64-linux-musl/include/asm-generic \ - && ls -l /usr/local/x86_64-linux-musl \ - && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \ - ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ - else \ - mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \ - mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ - cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \ - unlink /usr/local/x86_64-linux-musl/lib/lib64; \ - rm -rf /usr/local/x86_64-linux-musl/abc; \ - fi \ + /usr/local/aarch64-linux-gnu/include/linux \ + /usr/local/aarch64-linux-gnu/include/asm \ + /usr/local/aarch64-linux-gnu/include/asm-generic \ + && ls -l /usr/local/aarch64-linux-gnu \ && cd .. \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true @@ -158,22 +147,20 @@ RUN set -eux \ RUN set -eux \ && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ && cd "openssl-${OPENSSL_VERSION}" \ - && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64..." \ - && ls /usr/include/linux \ - && mkdir -p /usr/local/aarch64-linux-gnu/include \ - && env CC=aarch64-linux-gnu-gcc ./Configure no-shared no-zlib \ - -fPIC --prefix=/usr/local/aarch64-linux-gnu \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64 musl..." \ + && mkdir -p /usr/local/aarch64-linux-musl/include \ + && env CC=aarch64-linux-musl-gcc \ + ./Configure no-shared no-engine no-zlib \ + -fPIC --prefix=/usr/local/aarch64-linux-musl \ -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ - && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make depend \ - && env C_INCLUDE_PATH=/usr/local/aarch64-linux-gnu/include/ make -j$(nproc) \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make -j$(nproc) \ && make -j$(nproc) install_sw \ && make -j$(nproc) install_ssldirs \ - && openssl version \ && rm -rf \ - /usr/local/aarch64-linux-gnu/include/linux \ - /usr/local/aarch64-linux-gnu/include/asm \ - /usr/local/aarch64-linux-gnu/include/asm-generic \ - && ls -l /usr/local/aarch64-linux-gnu \ + /usr/local/aarch64-linux-musl/include/asm \ + /usr/local/aarch64-linux-musl/include/asm-generic \ + && ls -l /usr/local/aarch64-linux-musl \ && cd .. \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true @@ -216,34 +203,44 @@ RUN set -eux \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true -RUN set -eux \ - && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ - && cd "openssl-${OPENSSL_VERSION}" \ - && echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64 musl..." \ - && mkdir -p /usr/local/aarch64-linux-musl/include \ - && env CC=aarch64-linux-musl-gcc \ - ./Configure no-asm no-engine no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ - -fPIC --prefix=/usr/local/aarch64-linux-musl \ - -DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \ - && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make depend \ - && env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make -j$(nproc) \ - && make -j$(nproc) install_sw \ - && make -j$(nproc) install_ssldirs \ - && rm -rf \ - /usr/local/aarch64-linux-musl/include/asm \ - /usr/local/aarch64-linux-musl/include/asm-generic \ - && ls -l /usr/local/aarch64-linux-musl \ - && cd .. \ - && rm -rf "openssl-${OPENSSL_VERSION}" \ - && true +# TODO: +# RUN set -eux \ +# && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ +# && cd "openssl-${OPENSSL_VERSION}" \ +# && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \ +# && mkdir -p /usr/local/x86_64-linux-musl/include \ +# && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ +# && env CC=x86_64-linux-musl-gcc \ +# ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ +# -fPIC --prefix=/usr/local/x86_64-linux-musl \ +# -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ +# && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ +# && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \ +# && make -j$(nproc) install_sw \ +# && make -j$(nproc) install_ssldirs \ +# && rm -rf \ +# /usr/local/x86_64-linux-musl/include/asm \ +# && ls -l /usr/local/x86_64-linux-musl \ +# && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \ +# ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ +# else \ +# mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \ +# mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ +# cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \ +# unlink /usr/local/x86_64-linux-musl/lib/lib64; \ +# rm -rf /usr/local/x86_64-linux-musl/abc; \ +# fi \ +# && cd .. \ +# && rm -rf "openssl-${OPENSSL_VERSION}" \ +# && true RUN set -eux \ && echo "Testing musl-gcc with OpenSSL..." \ && openssl version \ && echo "int main(){return 0;}" | \ musl-gcc -o test -x c - \ - -I/usr/local/x86_64-linux-musl/include \ - -L/usr/local/x86_64-linux-musl/lib \ + -I/usr/local/aarch64-linux-musl/include \ + -L/usr/local/aarch64-linux-musl/lib \ -lssl -lcrypto \ && true From e5f483dd443030747f75009afa5493b23350b019 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Sat, 4 Oct 2025 23:09:45 +0200 Subject: [PATCH 06/19] chore: add missing x86_64 toolchain --- .github/workflows/devel.yml | 2 ++ docker/amd64/Dockerfile | 11 ++++++----- docker/arm64/Dockerfile | 11 ++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 017d766..7536230 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -76,6 +76,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 + push: ${{ github.event_name != 'pull_request' }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - @@ -169,6 +170,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 + push: ${{ github.event_name != 'pull_request' }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile index 6f7e979..1e1de8f 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/Dockerfile @@ -34,6 +34,7 @@ RUN set -eux \ aarch64-unknown-linux-musl \ x86_64-apple-darwin \ x86_64-unknown-linux-musl \ + x86_64-unknown-linux-gnu \ && true COPY cargo/config.toml /root/.cargo/config.toml @@ -45,10 +46,6 @@ RUN set -eux \ ##### Libraries -# pkg-config related environment variables -ENV PKG_CONFIG_ALLOW_CROSS=true -ENV PKG_CONFIG_ALL_STATIC=true - RUN set -eux \ && dpkg --add-architecture arm64 \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ @@ -71,7 +68,7 @@ RUN set -eux \ && echo "Downloading zlib ${ZLIB_VERSION}..." \ && curl -Lo zlib.tar.gz "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ && true - + # x86_64 glibc RUN set -eux \ && mkdir zlib \ @@ -255,6 +252,10 @@ RUN set -eux \ WORKDIR /root +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=true +ENV PKG_CONFIG_ALL_STATIC=true + # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index 13bb436..dbaede0 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -34,6 +34,7 @@ RUN set -eux \ aarch64-unknown-linux-musl \ x86_64-apple-darwin \ x86_64-unknown-linux-musl \ + x86_64-unknown-linux-gnu \ && true COPY cargo/config.toml /root/.cargo/config.toml @@ -45,10 +46,6 @@ RUN set -eux \ ##### Libraries -# pkg-config related environment variables -ENV PKG_CONFIG_ALLOW_CROSS=true -ENV PKG_CONFIG_ALL_STATIC=true - RUN set -eux \ && dpkg --add-architecture amd64 \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ @@ -71,7 +68,7 @@ RUN set -eux \ && echo "Downloading zlib ${ZLIB_VERSION}..." \ && curl -Lo zlib.tar.gz "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \ && true - + # x86_64 glibc RUN set -eux \ && mkdir zlib \ @@ -252,6 +249,10 @@ RUN set -eux \ WORKDIR /root +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=true +ENV PKG_CONFIG_ALL_STATIC=true + # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl From f54697982f507b0fc6d2983e951b388357d3b0cd Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Mon, 6 Oct 2025 10:28:29 +0200 Subject: [PATCH 07/19] chore: fix amd64 and arm64 docker images tests --- .dockerignore | 2 +- Makefile | 64 +++++++++++--------- docker/amd64/Dockerfile | 3 +- cargo/config.toml => docker/amd64/cargo.toml | 3 +- docker/arm64/Dockerfile | 63 ++++++++++--------- docker/arm64/cargo.toml | 18 ++++++ 6 files changed, 90 insertions(+), 63 deletions(-) rename cargo/config.toml => docker/amd64/cargo.toml (92%) create mode 100644 docker/arm64/cargo.toml diff --git a/.dockerignore b/.dockerignore index 0fb8590..44cd6ff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ * -!cargo +!docker !Dockerfile !Makefile !scripts diff --git a/Makefile b/Makefile index 2f40d15..355b1d0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ REPOSITORY ?= joseluisq TAG ?= latest - build-amd64: docker build \ -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \ @@ -9,6 +8,15 @@ build-amd64: -f docker/amd64/Dockerfile . .PHONY: build-amd64 +run-amd64: + @docker run --rm -it \ + -v $(PWD):/root/src \ + -v $(PWD)/docker/amd64/cargo.toml:/root/.cargo/config.toml \ + -w /root/src \ + $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \ + bash +.PHONY: run-amd64 + build-arm64: docker buildx build \ -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \ @@ -17,6 +25,15 @@ build-arm64: -f docker/arm64/Dockerfile . .PHONY: build-arm64 +run-arm64: + @docker run --rm -it \ + -v $(PWD):/root/src \ + -v $(PWD)/docker/arm64/cargo.toml:/root/.cargo/config.toml \ + -w /root/src \ + $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \ + bash +.PHONY: run-arm64 + # Use to build both arm64 and amd64 images at the same time. # WARNING! Will automatically push, since multi-platform images are not available locally. # Use `REPOSITORY` arg to specify which container repository to push the images to. @@ -32,15 +49,6 @@ buildx: .PHONY: buildx -run: - @docker run --rm -it \ - -v $(PWD):/root/src \ - -v $(PWD)/cargo/config.toml:/root/.cargo/config.toml \ - -w /root/src \ - $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ - bash -.PHONY: run - test: @docker run --rm \ -v $(PWD):/root/src \ @@ -59,7 +67,7 @@ test-app: @cd tests/hello-world \ \ && echo "Compiling application (linux-gnu x86_64)..." \ - && cargo build --release --target x86_64-unknown-linux-gnu \ + && cargo build -v --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then \ target/x86_64-unknown-linux-gnu/release/hello-world-test; \ fi \ @@ -68,7 +76,7 @@ test-app: && echo \ \ && echo "Compiling application (linux-musl x86_64)..." \ - && cargo build --release --target x86_64-unknown-linux-musl \ + && cargo build -v --release --target x86_64-unknown-linux-musl \ && if [ "$$(uname -m)" = "x86_64" ]; then \ target/x86_64-unknown-linux-musl/release/hello-world-test; \ fi \ @@ -77,13 +85,13 @@ test-app: && echo \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ - && cargo build --release --target x86_64-apple-darwin \ + && cargo build -v --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/hello-world-test \ && file target/x86_64-apple-darwin/release/hello-world-test \ && echo \ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ - && cargo build --release --target aarch64-unknown-linux-gnu \ + && cargo build -v --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-gnu/release/hello-world-test; \ fi \ @@ -92,7 +100,7 @@ test-app: && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ - && cargo build --release --target aarch64-unknown-linux-musl \ + && cargo build -v --release --target aarch64-unknown-linux-musl \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-musl/release/hello-world-test; \ fi \ @@ -101,7 +109,7 @@ test-app: && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ - && cargo build --release --target aarch64-apple-darwin \ + && cargo build -v --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/hello-world-test \ && file target/aarch64-apple-darwin/release/hello-world-test \ && echo @@ -117,7 +125,7 @@ test-zlib: @cd tests/zlib \ \ && echo "Compiling application (linux-gnu x86_64)..." \ - && cargo build --release --target x86_64-unknown-linux-gnu \ + && cargo build -v --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then target/x86_64-unknown-linux-gnu/release/zlib-test; \ fi \ @@ -126,7 +134,7 @@ test-zlib: && echo \ \ && echo "Compiling application (linux-musl x86_64)..." \ - && cargo build --release --target x86_64-unknown-linux-musl \ + && cargo build -v --release --target x86_64-unknown-linux-musl \ && if [ "$$(uname -m)" = "x86_64" ]; then target/x86_64-unknown-linux-musl/release/zlib-test; \ fi \ @@ -136,14 +144,14 @@ test-zlib: \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ && CC=o64-clang CXX=o64-clang++ \ - cargo build --release --target x86_64-apple-darwin \ + cargo build -v --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/zlib-test \ && file target/x86_64-apple-darwin/release/zlib-test \ && echo \ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ && CC=aarch64-linux-gnu-gcc \ - cargo build --release --target aarch64-unknown-linux-gnu \ + cargo build -v --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-gnu/release/zlib-test; \ fi \ @@ -152,7 +160,7 @@ test-zlib: && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ - && cargo build --release --target aarch64-unknown-linux-musl \ + && cargo build -v --release --target aarch64-unknown-linux-musl \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-musl/release/zlib-test; \ fi \ @@ -162,7 +170,7 @@ test-zlib: \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ && CC=oa64-clang CXX=oa64-clang++ \ - cargo build --release --target aarch64-apple-darwin \ + cargo build -v --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/zlib-test \ && file target/aarch64-apple-darwin/release/zlib-test \ && echo \ @@ -179,7 +187,7 @@ test-openssl: @cd tests/openssl \ \ && echo "Compiling application (linux-gnu x86_64)..." \ - && cargo build --release --target x86_64-unknown-linux-gnu \ + && cargo build -v --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then \ target/x86_64-unknown-linux-gnu/release/openssl; \ fi \ @@ -189,7 +197,7 @@ test-openssl: \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ && CC=aarch64-linux-gnu-gcc \ - cargo build --release --target aarch64-unknown-linux-gnu \ + cargo build -v --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-gnu/release/openssl; \ fi \ @@ -199,7 +207,7 @@ test-openssl: \ && echo "Compiling application (linux-musl x86_64)..." \ && OPENSSL_STATIC=1 \ - cargo build --release --target x86_64-unknown-linux-musl \ + cargo build -v --release --target x86_64-unknown-linux-musl \ && if [ "$$(uname -m)" = "x86_64" ]; then \ target/x86_64-unknown-linux-musl/release/openssl; \ fi \ @@ -210,14 +218,14 @@ test-openssl: && echo "Cross-compiling application (apple-darwin x86_64)..." \ && OPENSSL_STATIC=1 \ CC=o64-clang CXX=o64-clang++ \ - cargo build --release --target x86_64-apple-darwin \ + cargo build -v --release --target x86_64-apple-darwin \ && du -sh target/x86_64-apple-darwin/release/openssl \ && file target/x86_64-apple-darwin/release/openssl \ && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ && OPENSSL_STATIC=1 \ - cargo build --release --target aarch64-unknown-linux-musl \ + cargo build -v --release --target aarch64-unknown-linux-musl \ && if [ "$$(uname -m)" = "aarch64" ]; then \ target/aarch64-unknown-linux-musl/release/openssl; fi \ @@ -228,7 +236,7 @@ test-openssl: && echo "Cross-compiling application (apple-darwin aarch64)..." \ && OPENSSL_STATIC=1 \ CC=oa64-clang CXX=oa64-clang++ \ - cargo build --release --target aarch64-apple-darwin \ + cargo build -v --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/openssl \ && file target/aarch64-apple-darwin/release/openssl \ && echo diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile index 1e1de8f..0a23d16 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/Dockerfile @@ -37,7 +37,7 @@ RUN set -eux \ x86_64-unknown-linux-gnu \ && true -COPY cargo/config.toml /root/.cargo/config.toml +COPY docker/amd64/cargo.toml /root/.cargo/config.toml RUN set -eux \ && rustc -vV \ @@ -259,6 +259,7 @@ ENV PKG_CONFIG_ALL_STATIC=true # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl +ENV X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/x86_64-linux-musl ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 diff --git a/cargo/config.toml b/docker/amd64/cargo.toml similarity index 92% rename from cargo/config.toml rename to docker/amd64/cargo.toml index 492c816..63d7c6e 100644 --- a/cargo/config.toml +++ b/docker/amd64/cargo.toml @@ -1,4 +1,5 @@ [build] + # Target musl-libc by default when running Cargo target = "x86_64-unknown-linux-musl" @@ -6,7 +7,7 @@ target = "x86_64-unknown-linux-musl" linker = "aarch64-linux-gnu-gcc" [target.aarch64-unknown-linux-musl] -linker = "aarch64-linux-gnu-gcc" +linker = "aarch64-linux-musl-gcc" [target.x86_64-apple-darwin] linker = "x86_64-apple-darwin22.4-clang" diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index dbaede0..778dc28 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -37,7 +37,7 @@ RUN set -eux \ x86_64-unknown-linux-gnu \ && true -COPY cargo/config.toml /root/.cargo/config.toml +COPY docker/arm64/cargo.toml /root/.cargo/config.toml RUN set -eux \ && rustc -vV \ @@ -200,36 +200,35 @@ RUN set -eux \ && rm -rf "openssl-${OPENSSL_VERSION}" \ && true -# TODO: -# RUN set -eux \ -# && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ -# && cd "openssl-${OPENSSL_VERSION}" \ -# && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \ -# && mkdir -p /usr/local/x86_64-linux-musl/include \ -# && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ -# && env CC=x86_64-linux-musl-gcc \ -# ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ -# -fPIC --prefix=/usr/local/x86_64-linux-musl \ -# -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ -# && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ -# && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \ -# && make -j$(nproc) install_sw \ -# && make -j$(nproc) install_ssldirs \ -# && rm -rf \ -# /usr/local/x86_64-linux-musl/include/asm \ -# && ls -l /usr/local/x86_64-linux-musl \ -# && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \ -# ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ -# else \ -# mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \ -# mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ -# cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \ -# unlink /usr/local/x86_64-linux-musl/lib/lib64; \ -# rm -rf /usr/local/x86_64-linux-musl/abc; \ -# fi \ -# && cd .. \ -# && rm -rf "openssl-${OPENSSL_VERSION}" \ -# && true +RUN set -eux \ + && tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \ + && cd "openssl-${OPENSSL_VERSION}" \ + && echo "Building OpenSSL ${OPENSSL_VERSION} for x86_64..." \ + && mkdir -p /usr/local/x86_64-linux-musl/include \ + && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ + && env CC=x86_64-linux-musl-gcc \ + ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + -fPIC --prefix=/usr/local/x86_64-linux-musl \ + -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ + && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ + && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make -j$(nproc) \ + && make -j$(nproc) install_sw \ + && make -j$(nproc) install_ssldirs \ + && rm -rf \ + /usr/local/x86_64-linux-musl/include/asm \ + && ls -l /usr/local/x86_64-linux-musl \ + && if ! [ -d /usr/local/x86_64-linux-musl/lib ]; then \ + ln -s /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ + else \ + mv /usr/local/x86_64-linux-musl/lib /usr/local/x86_64-linux-musl/abc; \ + mv /usr/local/x86_64-linux-musl/lib64 /usr/local/x86_64-linux-musl/lib; \ + cp -rp /usr/local/x86_64-linux-musl/abc/. /usr/local/x86_64-linux-musl/lib/; \ + unlink /usr/local/x86_64-linux-musl/lib/lib64; \ + rm -rf /usr/local/x86_64-linux-musl/abc; \ + fi \ + && cd .. \ + && rm -rf "openssl-${OPENSSL_VERSION}" \ + && true RUN set -eux \ && echo "Testing musl-gcc with OpenSSL..." \ @@ -261,7 +260,7 @@ ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-musl -ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-gnu +ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-musl ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin WORKDIR /root/src diff --git a/docker/arm64/cargo.toml b/docker/arm64/cargo.toml new file mode 100644 index 0000000..1f47ea4 --- /dev/null +++ b/docker/arm64/cargo.toml @@ -0,0 +1,18 @@ +[build] + +# Target musl-libc by default when running Cargo +target = "aarch64-unknown-linux-musl" + +[target.x86_64-unknown-linux-gnu] +linker = "x86_64-linux-gnu-gcc" + +[target.x86_64-unknown-linux-musl] +linker = "x86_64-linux-musl-gcc" + +[target.x86_64-apple-darwin] +linker = "x86_64-apple-darwin22.4-clang" +ar = "x86_64-apple-darwin22.4-ar" + +[target.aarch64-apple-darwin] +linker = "arm64e-apple-darwin22.4-clang" +ar = "arm64e-apple-darwin22.4-ar" From da6de7bd1ca82d2eff62d3b268e339f961399ca5 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Tue, 7 Oct 2025 17:14:08 +0200 Subject: [PATCH 08/19] fix: linux x86_64 openssl build for docker arm64 image --- Makefile | 69 ++++++++++++++------------ docker/arm64/Dockerfile | 2 +- tests/{hello-world => app}/Cargo.lock | 4 +- tests/{hello-world => app}/Cargo.toml | 2 +- tests/{hello-world => app}/src/main.rs | 0 tests/openssl/Cargo.lock | 14 +++--- tests/openssl/Cargo.toml | 4 +- tests/zlib/Cargo.lock | 11 +++- tests/zlib/Cargo.toml | 2 +- 9 files changed, 59 insertions(+), 49 deletions(-) rename tests/{hello-world => app}/Cargo.lock (76%) rename tests/{hello-world => app}/Cargo.toml (85%) rename tests/{hello-world => app}/src/main.rs (100%) diff --git a/Makefile b/Makefile index 355b1d0..02f141e 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,9 @@ test: bash -c 'set -eu; make test-app; make test-zlib; make test-openssl' .PHONY: test +test-all: test-app test-zlib test-openssl +.PHONY: test-all + test-app: @echo "Checking Debian version..." @cat /etc/debian_version @@ -64,54 +67,54 @@ test-app: @echo "Testing cross-compiling application..." @rustc -vV @echo - @cd tests/hello-world \ + @cd tests/app \ \ && echo "Compiling application (linux-gnu x86_64)..." \ && cargo build -v --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then \ - target/x86_64-unknown-linux-gnu/release/hello-world-test; \ + target/x86_64-unknown-linux-gnu/release/app-test; \ fi \ - && du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test \ - && file target/x86_64-unknown-linux-gnu/release/hello-world-test \ + && du -sh target/x86_64-unknown-linux-gnu/release/app-test \ + && file target/x86_64-unknown-linux-gnu/release/app-test \ && echo \ \ && echo "Compiling application (linux-musl x86_64)..." \ && cargo build -v --release --target x86_64-unknown-linux-musl \ && if [ "$$(uname -m)" = "x86_64" ]; then \ - target/x86_64-unknown-linux-musl/release/hello-world-test; \ + target/x86_64-unknown-linux-musl/release/app-test; \ fi \ - && du -sh target/x86_64-unknown-linux-musl/release/hello-world-test \ - && file target/x86_64-unknown-linux-musl/release/hello-world-test \ + && du -sh target/x86_64-unknown-linux-musl/release/app-test \ + && file target/x86_64-unknown-linux-musl/release/app-test \ && echo \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ && cargo build -v --release --target x86_64-apple-darwin \ - && du -sh target/x86_64-apple-darwin/release/hello-world-test \ - && file target/x86_64-apple-darwin/release/hello-world-test \ + && du -sh target/x86_64-apple-darwin/release/app-test \ + && file target/x86_64-apple-darwin/release/app-test \ && echo \ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ && cargo build -v --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ - target/aarch64-unknown-linux-gnu/release/hello-world-test; \ + target/aarch64-unknown-linux-gnu/release/app-test; \ fi \ - && du -sh target/aarch64-unknown-linux-gnu/release/hello-world-test \ - && file target/aarch64-unknown-linux-gnu/release/hello-world-test \ + && du -sh target/aarch64-unknown-linux-gnu/release/app-test \ + && file target/aarch64-unknown-linux-gnu/release/app-test \ && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ && cargo build -v --release --target aarch64-unknown-linux-musl \ && if [ "$$(uname -m)" = "aarch64" ]; then \ - target/aarch64-unknown-linux-musl/release/hello-world-test; \ + target/aarch64-unknown-linux-musl/release/app-test; \ fi \ - && du -sh target/aarch64-unknown-linux-musl/release/hello-world-test \ - && file target/aarch64-unknown-linux-musl/release/hello-world-test \ + && du -sh target/aarch64-unknown-linux-musl/release/app-test \ + && file target/aarch64-unknown-linux-musl/release/app-test \ && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ && cargo build -v --release --target aarch64-apple-darwin \ - && du -sh target/aarch64-apple-darwin/release/hello-world-test \ - && file target/aarch64-apple-darwin/release/hello-world-test \ + && du -sh target/aarch64-apple-darwin/release/app-test \ + && file target/aarch64-apple-darwin/release/app-test \ && echo .ONESHELL: test-app @@ -189,56 +192,56 @@ test-openssl: && echo "Compiling application (linux-gnu x86_64)..." \ && cargo build -v --release --target x86_64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "x86_64" ]; then \ - target/x86_64-unknown-linux-gnu/release/openssl; \ + target/x86_64-unknown-linux-gnu/release/openssl-test; \ fi \ - && du -sh target/x86_64-unknown-linux-gnu/release/openssl \ - && file target/x86_64-unknown-linux-gnu/release/openssl \ + && du -sh target/x86_64-unknown-linux-gnu/release/openssl-test \ + && file target/x86_64-unknown-linux-gnu/release/openssl-test \ && echo \ \ && echo "Cross-compiling application (linux-gnu aarch64)..." \ && CC=aarch64-linux-gnu-gcc \ cargo build -v --release --target aarch64-unknown-linux-gnu \ && if [ "$$(uname -m)" = "aarch64" ]; then \ - target/aarch64-unknown-linux-gnu/release/openssl; \ + target/aarch64-unknown-linux-gnu/release/openssl-test; \ fi \ - && du -sh target/aarch64-unknown-linux-gnu/release/openssl \ - && file target/aarch64-unknown-linux-gnu/release/openssl \ + && du -sh target/aarch64-unknown-linux-gnu/release/openssl-test \ + && file target/aarch64-unknown-linux-gnu/release/openssl-test \ && echo \ \ && echo "Compiling application (linux-musl x86_64)..." \ && OPENSSL_STATIC=1 \ cargo build -v --release --target x86_64-unknown-linux-musl \ && if [ "$$(uname -m)" = "x86_64" ]; then \ - target/x86_64-unknown-linux-musl/release/openssl; \ + target/x86_64-unknown-linux-musl/release/openssl-test; \ fi \ - && du -sh target/x86_64-unknown-linux-musl/release/openssl \ - && file target/x86_64-unknown-linux-musl/release/openssl \ + && du -sh target/x86_64-unknown-linux-musl/release/openssl-test \ + && file target/x86_64-unknown-linux-musl/release/openssl-test \ && echo \ \ && echo "Cross-compiling application (apple-darwin x86_64)..." \ && OPENSSL_STATIC=1 \ CC=o64-clang CXX=o64-clang++ \ cargo build -v --release --target x86_64-apple-darwin \ - && du -sh target/x86_64-apple-darwin/release/openssl \ - && file target/x86_64-apple-darwin/release/openssl \ + && du -sh target/x86_64-apple-darwin/release/openssl-test \ + && file target/x86_64-apple-darwin/release/openssl-test \ && echo \ \ && echo "Cross-compiling application (linux-musl aarch64)..." \ && OPENSSL_STATIC=1 \ cargo build -v --release --target aarch64-unknown-linux-musl \ && if [ "$$(uname -m)" = "aarch64" ]; then \ - target/aarch64-unknown-linux-musl/release/openssl; + target/aarch64-unknown-linux-musl/release/openssl-test; fi \ - && du -sh target/aarch64-unknown-linux-musl/release/openssl \ - && file target/aarch64-unknown-linux-musl/release/openssl \ + && du -sh target/aarch64-unknown-linux-musl/release/openssl-test \ + && file target/aarch64-unknown-linux-musl/release/openssl-test \ && echo \ \ && echo "Cross-compiling application (apple-darwin aarch64)..." \ && OPENSSL_STATIC=1 \ CC=oa64-clang CXX=oa64-clang++ \ cargo build -v --release --target aarch64-apple-darwin \ - && du -sh target/aarch64-apple-darwin/release/openssl \ - && file target/aarch64-apple-darwin/release/openssl \ + && du -sh target/aarch64-apple-darwin/release/openssl-test \ + && file target/aarch64-apple-darwin/release/openssl-test \ && echo .ONESHELL: test-openssl diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index 778dc28..bcefa8a 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -207,7 +207,7 @@ RUN set -eux \ && mkdir -p /usr/local/x86_64-linux-musl/include \ && ln -s "/usr/include/x86_64-linux-gnu/asm" /usr/local/x86_64-linux-musl/include/asm \ && env CC=x86_64-linux-musl-gcc \ - ./Configure no-asm no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ + ./Configure no-asm no-engine no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \ -fPIC --prefix=/usr/local/x86_64-linux-musl \ -DOPENSSL_NO_SECURE_MEMORY "linux-x86_64" \ && env C_INCLUDE_PATH=/usr/local/x86_64-linux-musl/include/ make depend \ diff --git a/tests/hello-world/Cargo.lock b/tests/app/Cargo.lock similarity index 76% rename from tests/hello-world/Cargo.lock rename to tests/app/Cargo.lock index e1b1003..36a8ba1 100644 --- a/tests/hello-world/Cargo.lock +++ b/tests/app/Cargo.lock @@ -1,7 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "hello-world-test" +name = "app-test" version = "0.0.0" diff --git a/tests/hello-world/Cargo.toml b/tests/app/Cargo.toml similarity index 85% rename from tests/hello-world/Cargo.toml rename to tests/app/Cargo.toml index 7275b55..233a8ea 100644 --- a/tests/hello-world/Cargo.toml +++ b/tests/app/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "hello-world-test" +name = "app-test" version = "0.0.0" authors = ["Jose Quintana "] edition = "2021" diff --git a/tests/hello-world/src/main.rs b/tests/app/src/main.rs similarity index 100% rename from tests/hello-world/src/main.rs rename to tests/app/src/main.rs diff --git a/tests/openssl/Cargo.lock b/tests/openssl/Cargo.lock index 2a9bf33..4317d49 100644 --- a/tests/openssl/Cargo.lock +++ b/tests/openssl/Cargo.lock @@ -57,13 +57,6 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "openssl" -version = "0.0.0" -dependencies = [ - "openssl 0.10.73", -] - [[package]] name = "openssl" version = "0.10.73" @@ -102,6 +95,13 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "openssl-test" +version = "0.0.0" +dependencies = [ + "openssl", +] + [[package]] name = "pkg-config" version = "0.3.32" diff --git a/tests/openssl/Cargo.toml b/tests/openssl/Cargo.toml index e091b82..5c7c1a2 100644 --- a/tests/openssl/Cargo.toml +++ b/tests/openssl/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "openssl" +name = "openssl-test" version = "0.0.0" authors = ["Jose Quintana "] -edition = "2018" +edition = "2021" [dependencies] openssl = { version = "0.10.73" } diff --git a/tests/zlib/Cargo.lock b/tests/zlib/Cargo.lock index 26d337b..c904448 100644 --- a/tests/zlib/Cargo.lock +++ b/tests/zlib/Cargo.lock @@ -41,9 +41,9 @@ checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" dependencies = [ "crc32fast", "libz-sys", @@ -75,6 +75,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -89,6 +90,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/tests/zlib/Cargo.toml b/tests/zlib/Cargo.toml index 5dd611a..d357ee3 100644 --- a/tests/zlib/Cargo.toml +++ b/tests/zlib/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Jose Quintana "] edition = "2021" [dependencies] -flate2 = { version = "1.1.2", features = [ "zlib-default" ] } +flate2 = { version = "1.1.4", features = [ "zlib-default" ] } [profile.release] lto = true From a0266f4b1902a2e8785c757985725fddee3b227b Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Tue, 7 Oct 2025 17:27:09 +0200 Subject: [PATCH 09/19] fix: CI 'no space left on device' issue ------ > exporting to docker image format: ------ ------ > importing to docker: ------ ERROR: failed to build: failed to solve: rpc error: code = Unknown desc = write /root/.rustup/toolchains/1.87.0-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgimli-605c467c05f27091.rlib: no space left on device Reference Check build summary support Error: buildx failed with: ERROR: failed to build: failed to solve: rpc error: code = Unknown desc = write /root/.rustup/toolchains/1.87.0-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgimli-605c467c05f27091.rlib: no space left on device --- .github/workflows/devel.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 7536230..7a09a70 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -31,6 +31,13 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /opt/ghc + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf "/usr/local/share/boost" - name: Cache Docker layers uses: actions/cache@v4 @@ -125,6 +132,13 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /opt/ghc + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf "/usr/local/share/boost" - name: Cache Docker layers uses: actions/cache@v4 From 175cfe3ea3c541552d50017fa56033f11bc4b4a0 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Thu, 30 Oct 2025 15:18:13 +0100 Subject: [PATCH 10/19] chore: split up dockerfiles --- .github/workflows/devel.yml | 12 +-- Makefile | 133 ++++++++++++++++++++--------- docker/amd64/base/Dockerfile | 51 +++++++++++ docker/amd64/{ => base}/cargo.toml | 0 docker/amd64/{ => libs}/Dockerfile | 58 +------------ docker/arm64/base/Dockerfile | 51 +++++++++++ docker/arm64/{ => base}/cargo.toml | 0 docker/arm64/{ => libs}/Dockerfile | 58 +------------ 8 files changed, 208 insertions(+), 155 deletions(-) create mode 100644 docker/amd64/base/Dockerfile rename docker/amd64/{ => base}/cargo.toml (100%) rename docker/amd64/{ => libs}/Dockerfile (86%) create mode 100644 docker/arm64/base/Dockerfile rename docker/arm64/{ => base}/cargo.toml (100%) rename docker/arm64/{ => libs}/Dockerfile (85%) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 7a09a70..6de6ab4 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -77,7 +77,7 @@ jobs: with: context: . platforms: linux/amd64 - file: docker/amd64/Dockerfile + file: docker/amd64/base/Dockerfile load: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -107,8 +107,8 @@ jobs: cat /etc/debian_version uname -a make test-app - make test-zlib - make test-openssl + # make test-zlib + # make test-openssl - # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -178,7 +178,7 @@ jobs: with: context: . platforms: linux/arm64 - file: docker/arm64/Dockerfile + file: docker/arm64/base/Dockerfile load: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -208,8 +208,8 @@ jobs: cat /etc/debian_version uname -a make test-app - make test-zlib - make test-openssl + # make test-zlib + # make test-openssl - # Temp fix # https://github.com/docker/build-push-action/issues/252 diff --git a/Makefile b/Makefile index 02f141e..9304bdb 100644 --- a/Makefile +++ b/Makefile @@ -1,61 +1,104 @@ -REPOSITORY ?= joseluisq -TAG ?= latest +REPOSITORY ?= joseluisq/rust-linux-darwin-builder +TAG ?= devel -build-amd64: - docker build \ - -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \ +# AMD64 Tasks + +amd64-build: + docker buildx build \ + -t $(REPOSITORY):$(TAG)-amd64 \ --network=host \ - -f docker/amd64/Dockerfile . -.PHONY: build-amd64 + --platform linux/amd64 \ + -f docker/amd64/base/Dockerfile . +.PHONY: amd64-build -run-amd64: +amd64-run: @docker run --rm -it \ -v $(PWD):/root/src \ - -v $(PWD)/docker/amd64/cargo.toml:/root/.cargo/config.toml \ + -v $(PWD)/docker/amd64/base/cargo.toml:/root/.cargo/config.toml \ -w /root/src \ - $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-amd64 \ + $(REPOSITORY):$(TAG)-amd64 \ bash -.PHONY: run-amd64 +.PHONY: amd64-run + +amd64-test: + @docker run --rm \ + -v $(PWD):/root/src \ + -w /root/src \ + $(REPOSITORY):$(TAG)-amd64 \ + bash -c 'set -eu; test-app' +.PHONY: amd64-test -build-arm64: +amd64-build-libs: docker buildx build \ - -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \ + -t $(REPOSITORY):$(TAG)-amd64-libs \ --network=host \ - --platform linux/arm64 \ - -f docker/arm64/Dockerfile . -.PHONY: build-arm64 + --platform linux/amd64 \ + -f docker/amd64/libs/Dockerfile . +.PHONY: amd64-build-libs -run-arm64: +amd64-run-libs: @docker run --rm -it \ -v $(PWD):/root/src \ - -v $(PWD)/docker/arm64/cargo.toml:/root/.cargo/config.toml \ + -v $(PWD)/docker/amd64/libs/cargo.toml:/root/.cargo/config.toml \ -w /root/src \ - $(REPOSITORY)/rust-linux-darwin-builder:$(TAG)-arm64 \ + $(REPOSITORY):$(TAG)-amd64-libs \ bash -.PHONY: run-arm64 +.PHONY: amd64-run-libs -# Use to build both arm64 and amd64 images at the same time. -# WARNING! Will automatically push, since multi-platform images are not available locally. -# Use `REPOSITORY` arg to specify which container repository to push the images to. -buildx: - docker run --privileged --rm tonistiigi/binfmt --install linux/amd64,linux/arm64 - docker buildx create --name darwin-builder --driver docker-container --bootstrap - docker buildx use darwin-builder +amd64-test-libs: + @docker run --rm \ + -v $(PWD):/root/src \ + -w /root/src \ + $(REPOSITORY):$(TAG)-amd64-libs \ + bash -c 'set -eu; test-all' +.PHONY: amd64-test-libs + + +# ARM64 Tasks + +arm64-build: docker buildx build \ - --platform linux/amd64,linux/arm64 \ - --push \ - -t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ - -f Dockerfile . + -t $(REPOSITORY):$(TAG)-arm64 \ + --network=host \ + --platform linux/arm64 \ + -f docker/arm64/base/Dockerfile . +.PHONY: arm64-build -.PHONY: buildx +arm64-test: + @docker run --rm \ + -v $(PWD):/root/src \ + -w /root/src \ + $(REPOSITORY):$(TAG)-arm64 \ + bash -c 'set -eu; test-app' +.PHONY: arm64-test -test: +arm64-build-libs: + docker buildx build \ + -t $(REPOSITORY):$(TAG)-arm64-libs \ + --network=host \ + --platform linux/arm64 \ + -f docker/arm64/libs/Dockerfile . +.PHONY: arm64-build-libs + +arm64-run-libs: + @docker run --rm -it \ + -v $(PWD):/root/src \ + -v $(PWD)/docker/arm64/libs/cargo.toml:/root/.cargo/config.toml \ + -w /root/src \ + $(REPOSITORY):$(TAG)-arm64-libs \ + bash +.PHONY: arm64-run-libs + +arm64-test-libs: @docker run --rm \ -v $(PWD):/root/src \ -w /root/src \ - $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \ - bash -c 'set -eu; make test-app; make test-zlib; make test-openssl' -.PHONY: test + $(REPOSITORY):$(TAG)-arm64-libs \ + bash -c 'set -eu; test-all' +.PHONY: arm64-test-libs + + +# Testing Tasks (inside the container) test-all: test-app test-zlib test-openssl .PHONY: test-all @@ -176,8 +219,7 @@ test-zlib: cargo build -v --release --target aarch64-apple-darwin \ && du -sh target/aarch64-apple-darwin/release/zlib-test \ && file target/aarch64-apple-darwin/release/zlib-test \ - && echo \ - + && echo .ONESHELL: test-zlib test-openssl: @@ -243,5 +285,18 @@ test-openssl: && du -sh target/aarch64-apple-darwin/release/openssl-test \ && file target/aarch64-apple-darwin/release/openssl-test \ && echo - .ONESHELL: test-openssl + +# Use to build both arm64 and amd64 images at the same time. +# WARNING! Will automatically push, since multi-platform images are not available locally. +# Use `REPOSITORY` arg to specify which container repository to push the images to. +buildx: + docker run --privileged --rm tonistiigi/binfmt --install linux/amd64,linux/arm64 + docker buildx create --name darwin-builder --driver docker-container --bootstrap + docker buildx use darwin-builder + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --push \ + -t $(REPOSITORY):$(TAG) \ + -f Dockerfile . +.PHONY: buildx diff --git a/docker/amd64/base/Dockerfile b/docker/amd64/base/Dockerfile new file mode 100644 index 0000000..70e5b6a --- /dev/null +++ b/docker/amd64/base/Dockerfile @@ -0,0 +1,51 @@ +FROM joseluisq/docker-osxcross:1.0.0-beta.2 + +ARG VERSION=0.0.0 +ENV VERSION=${VERSION} + +# Rust stable toolchain +ARG TOOLCHAIN=1.87.0 + +LABEL version="${VERSION}" \ + description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + +# Static linking for C++ code +RUN set -eux \ + && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ + # Create appropriate directories for current user + && mkdir -p /root/libs /root/src \ + && true + +ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH + +##### Rust toolchains + +# Rust/Cargo related environment variables +ENV TARGET=musl + +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=1 +ENV PKG_CONFIG_ALL_STATIC=1 + +RUN set -eux \ + && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ + && rustup target add \ + aarch64-apple-darwin \ + aarch64-unknown-linux-gnu \ + aarch64-unknown-linux-musl \ + x86_64-apple-darwin \ + x86_64-unknown-linux-musl \ + x86_64-unknown-linux-gnu \ + && true + +COPY docker/amd64/base/cargo.toml /root/.cargo/config.toml + +RUN set -eux \ + && rustc -vV \ + && cargo -vV \ + && true + +WORKDIR /root/src + +CMD ["bash"] diff --git a/docker/amd64/cargo.toml b/docker/amd64/base/cargo.toml similarity index 100% rename from docker/amd64/cargo.toml rename to docker/amd64/base/cargo.toml diff --git a/docker/amd64/Dockerfile b/docker/amd64/libs/Dockerfile similarity index 86% rename from docker/amd64/Dockerfile rename to docker/amd64/libs/Dockerfile index 0a23d16..d3817d1 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/libs/Dockerfile @@ -1,50 +1,4 @@ -FROM joseluisq/docker-osxcross:1.0.0-beta.2 - -ARG VERSION=0.0.0 -ENV VERSION=${VERSION} - -LABEL version="${VERSION}" \ - description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ - maintainer="Jose Quintana " - -# Static linking for C++ code -RUN set -eux \ - && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ - # Create appropriate directories for current user - && mkdir -p /root/libs /root/src \ - && true - -ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH - -##### Rust toolchains - -# Rust/Cargo related environment variables -ENV TARGET=musl -# Crate-related environment variables -ENV LIBZ_SYS_STATIC=1 - -# Rust stable toolchain -ARG TOOLCHAIN=1.87.0 - -RUN set -eux \ - && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ - && rustup target add \ - aarch64-apple-darwin \ - aarch64-unknown-linux-gnu \ - aarch64-unknown-linux-musl \ - x86_64-apple-darwin \ - x86_64-unknown-linux-musl \ - x86_64-unknown-linux-gnu \ - && true - -COPY docker/amd64/cargo.toml /root/.cargo/config.toml - -RUN set -eux \ - && rustc -vV \ - && cargo -vV \ - && true - -##### Libraries +FROM joseluisq/rust-linux-darwin-builder:v2.0.0-beta.1 RUN set -eux \ && dpkg --add-architecture arm64 \ @@ -61,6 +15,8 @@ RUN set -eux \ # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 +# Crate-related environment variables +ENV LIBZ_SYS_STATIC=1 WORKDIR /tmp @@ -250,12 +206,6 @@ RUN set -eux \ && rm -rf /tmp/* \ && true -WORKDIR /root - -# pkg-config related environment variables -ENV PKG_CONFIG_ALLOW_CROSS=true -ENV PKG_CONFIG_ALL_STATIC=true - # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl @@ -268,5 +218,3 @@ ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-gnu ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin WORKDIR /root/src - -CMD ["bash"] diff --git a/docker/arm64/base/Dockerfile b/docker/arm64/base/Dockerfile new file mode 100644 index 0000000..401500c --- /dev/null +++ b/docker/arm64/base/Dockerfile @@ -0,0 +1,51 @@ +FROM joseluisq/docker-osxcross:1.0.0-beta.1 + +ARG VERSION=0.0.0 +ENV VERSION=${VERSION} + +# Rust stable toolchain +ARG TOOLCHAIN=1.87.0 + +LABEL version="${VERSION}" \ + description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + +# Static linking for C++ code +RUN set -eux \ + && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ + # Create appropriate directories for current user + && mkdir -p /root/libs /root/src \ + && true + +ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH + +##### Rust toolchains + +# Rust/Cargo related environment variables +ENV TARGET=musl + +# pkg-config related environment variables +ENV PKG_CONFIG_ALLOW_CROSS=1 +ENV PKG_CONFIG_ALL_STATIC=1 + +RUN set -eux \ + && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ + && rustup target add \ + aarch64-apple-darwin \ + aarch64-unknown-linux-gnu \ + aarch64-unknown-linux-musl \ + x86_64-apple-darwin \ + x86_64-unknown-linux-musl \ + x86_64-unknown-linux-gnu \ + && true + +COPY docker/arm64/base/cargo.toml /root/.cargo/config.toml + +RUN set -eux \ + && rustc -vV \ + && cargo -vV \ + && true + +WORKDIR /root/src + +CMD ["bash"] diff --git a/docker/arm64/cargo.toml b/docker/arm64/base/cargo.toml similarity index 100% rename from docker/arm64/cargo.toml rename to docker/arm64/base/cargo.toml diff --git a/docker/arm64/Dockerfile b/docker/arm64/libs/Dockerfile similarity index 85% rename from docker/arm64/Dockerfile rename to docker/arm64/libs/Dockerfile index bcefa8a..bf1a830 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/libs/Dockerfile @@ -1,50 +1,4 @@ -FROM joseluisq/docker-osxcross:1.0.0-beta.2 - -ARG VERSION=0.0.0 -ENV VERSION=${VERSION} - -LABEL version="${VERSION}" \ - description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ - maintainer="Jose Quintana " - -# Static linking for C++ code -RUN set -eux \ - && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ - # Create appropriate directories for current user - && mkdir -p /root/libs /root/src \ - && true - -ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH - -##### Rust toolchains - -# Rust/Cargo related environment variables -ENV TARGET=musl -# Crate-related environment variables -ENV LIBZ_SYS_STATIC=1 - -# Rust stable toolchain -ARG TOOLCHAIN=1.87.0 - -RUN set -eux \ - && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TOOLCHAIN \ - && rustup target add \ - aarch64-apple-darwin \ - aarch64-unknown-linux-gnu \ - aarch64-unknown-linux-musl \ - x86_64-apple-darwin \ - x86_64-unknown-linux-musl \ - x86_64-unknown-linux-gnu \ - && true - -COPY docker/arm64/cargo.toml /root/.cargo/config.toml - -RUN set -eux \ - && rustc -vV \ - && cargo -vV \ - && true - -##### Libraries +FROM joseluisq/rust-linux-darwin-builder:v2.0.0-beta.1 RUN set -eux \ && dpkg --add-architecture amd64 \ @@ -61,6 +15,8 @@ RUN set -eux \ # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 +# Crate-related environment variables +ENV LIBZ_SYS_STATIC=1 WORKDIR /tmp @@ -246,12 +202,6 @@ RUN set -eux \ && rm -rf /tmp/* \ && true -WORKDIR /root - -# pkg-config related environment variables -ENV PKG_CONFIG_ALLOW_CROSS=true -ENV PKG_CONFIG_ALL_STATIC=true - # OpenSSL related environment variables ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1 ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl @@ -264,5 +214,3 @@ ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-musl ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin WORKDIR /root/src - -CMD ["bash"] From 5409d3762c3de1cfbff7c90388d4e578afc3a54d Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Thu, 30 Oct 2025 15:28:57 +0100 Subject: [PATCH 11/19] chore: move required system libraries to base dockerfiles --- .github/workflows/release-beta.yml | 4 ++-- docker/amd64/base/Dockerfile | 13 +++++++++++++ docker/amd64/libs/Dockerfile | 13 ------------- docker/arm64/base/Dockerfile | 13 +++++++++++++ docker/arm64/libs/Dockerfile | 13 ------------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 80a6732..667f768 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -54,7 +54,7 @@ jobs: provenance: false context: . platforms: linux/amd64 - file: ./docker/amd64/Dockerfile + file: ./docker/amd64/base/Dockerfile tags: ${{ steps.meta.outputs.tags }} build-arm64: @@ -105,7 +105,7 @@ jobs: provenance: false context: . platforms: linux/arm64 - file: ./docker/arm64/Dockerfile + file: ./docker/arm64/base/Dockerfile tags: ${{ steps.meta.outputs.tags }} manifest: diff --git a/docker/amd64/base/Dockerfile b/docker/amd64/base/Dockerfile index 70e5b6a..0e79d28 100644 --- a/docker/amd64/base/Dockerfile +++ b/docker/amd64/base/Dockerfile @@ -10,6 +10,19 @@ LABEL version="${VERSION}" \ description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ maintainer="Jose Quintana " +RUN set -eux \ + && dpkg --add-architecture arm64 \ + && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ + musl-dev \ + musl-dev:arm64 \ + musl-tools \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && true + # Static linking for C++ code RUN set -eux \ && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ diff --git a/docker/amd64/libs/Dockerfile b/docker/amd64/libs/Dockerfile index d3817d1..95a3f35 100644 --- a/docker/amd64/libs/Dockerfile +++ b/docker/amd64/libs/Dockerfile @@ -1,18 +1,5 @@ FROM joseluisq/rust-linux-darwin-builder:v2.0.0-beta.1 -RUN set -eux \ - && dpkg --add-architecture arm64 \ - && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ - musl-dev \ - musl-dev:arm64 \ - musl-tools \ - gcc-aarch64-linux-gnu \ - g++-aarch64-linux-gnu \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - && true - # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 # Crate-related environment variables diff --git a/docker/arm64/base/Dockerfile b/docker/arm64/base/Dockerfile index 401500c..590c0a1 100644 --- a/docker/arm64/base/Dockerfile +++ b/docker/arm64/base/Dockerfile @@ -10,6 +10,19 @@ LABEL version="${VERSION}" \ description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ maintainer="Jose Quintana " +RUN set -eux \ + && dpkg --add-architecture amd64 \ + && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ + musl-dev \ + musl-dev:amd64 \ + musl-tools \ + gcc-x86-64-linux-gnu \ + g++-x86-64-linux-gnu \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && true + # Static linking for C++ code RUN set -eux \ && ln -s "/usr/bin/g++" "/usr/bin/musl-g++" \ diff --git a/docker/arm64/libs/Dockerfile b/docker/arm64/libs/Dockerfile index bf1a830..8931fcd 100644 --- a/docker/arm64/libs/Dockerfile +++ b/docker/arm64/libs/Dockerfile @@ -1,18 +1,5 @@ FROM joseluisq/rust-linux-darwin-builder:v2.0.0-beta.1 -RUN set -eux \ - && dpkg --add-architecture amd64 \ - && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ - musl-dev \ - musl-dev:amd64 \ - musl-tools \ - gcc-x86-64-linux-gnu \ - g++-x86-64-linux-gnu \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ - && true - # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 # Crate-related environment variables From 6c2cad50a7d1c75cbba37dadfa862c4f480d749b Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Thu, 30 Oct 2025 23:23:13 +0100 Subject: [PATCH 12/19] chore: add devel ci workflow for libs dockerfiles --- .github/workflows/devel.yml | 214 ++++++++++++++++++++++++++++- .github/workflows/release-beta.yml | 1 - Makefile | 14 +- docker/amd64/libs/Dockerfile | 4 +- docker/arm64/libs/Dockerfile | 4 +- 5 files changed, 221 insertions(+), 16 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 6de6ab4..52edb97 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -66,6 +66,7 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha + type=raw,value=devel,suffix=-amd64 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -107,8 +108,6 @@ jobs: cat /etc/debian_version uname -a make test-app - # make test-zlib - # make test-openssl - # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -167,6 +166,7 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha + type=raw,value=devel,suffix=-arm64 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -208,8 +208,214 @@ jobs: cat /etc/debian_version uname -a make test-app - # make test-zlib - # make test-openssl + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + docker-amd64-libs: + needs: + - docker-amd64 + name: Docker test libs (amd64) + runs-on: ubuntu-22.04 + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /opt/ghc + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf "/usr/local/share/boost" + - + name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: rust-linux-darwin-builder-amd64-libs-buildx-${{ github.sha }} + restore-keys: | + rust-linux-darwin-builder-amd64-libs-buildx- + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + flavor: | + latest=false + suffix=-amd64-libs + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + - + name: Build and export to Docker client + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + file: docker/amd64/libs/Dockerfile + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-amd64 + push: ${{ github.event_name != 'pull_request' }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - + name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Check manifest + if: github.event_name != 'pull_request' + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Run tests + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + docker-arm64-libs: + needs: + - docker-arm64 + name: Docker test libs (arm64) + runs-on: ubuntu-22.04-arm + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /opt/ghc + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf "/usr/local/share/boost" + - + name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: rust-linux-darwin-builder-arm64-libs-buildx-${{ github.sha }} + restore-keys: | + rust-linux-darwin-builder-arm64-libs-buildx- + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + flavor: | + latest=false + suffix=-arm64-libs + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + - + name: Build and export to Docker client + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/libs/Dockerfile + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-arm64 + push: ${{ github.event_name != 'pull_request' }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - + name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Check manifest + if: github.event_name != 'pull_request' + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Run tests + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl - # Temp fix # https://github.com/docker/build-push-action/issues/252 diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 667f768..f17268c 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -2,7 +2,6 @@ name: release-beta on: push: tags: - - 'v1.0.[0-9]+-beta.[0-9]+' - 'v2.0.[0-9]+-beta.[0-9]+' jobs: diff --git a/Makefile b/Makefile index 9304bdb..a5d95e5 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,9 @@ TAG ?= devel # AMD64 Tasks amd64-build: - docker buildx build \ + docker build \ -t $(REPOSITORY):$(TAG)-amd64 \ --network=host \ - --platform linux/amd64 \ -f docker/amd64/base/Dockerfile . .PHONY: amd64-build @@ -29,17 +28,16 @@ amd64-test: .PHONY: amd64-test amd64-build-libs: - docker buildx build \ + docker build \ -t $(REPOSITORY):$(TAG)-amd64-libs \ --network=host \ - --platform linux/amd64 \ -f docker/amd64/libs/Dockerfile . .PHONY: amd64-build-libs amd64-run-libs: @docker run --rm -it \ -v $(PWD):/root/src \ - -v $(PWD)/docker/amd64/libs/cargo.toml:/root/.cargo/config.toml \ + -v $(PWD)/docker/amd64/base/cargo.toml:/root/.cargo/config.toml \ -w /root/src \ $(REPOSITORY):$(TAG)-amd64-libs \ bash @@ -57,10 +55,9 @@ amd64-test-libs: # ARM64 Tasks arm64-build: - docker buildx build \ + docker build \ -t $(REPOSITORY):$(TAG)-arm64 \ --network=host \ - --platform linux/arm64 \ -f docker/arm64/base/Dockerfile . .PHONY: arm64-build @@ -73,10 +70,9 @@ arm64-test: .PHONY: arm64-test arm64-build-libs: - docker buildx build \ + docker build \ -t $(REPOSITORY):$(TAG)-arm64-libs \ --network=host \ - --platform linux/arm64 \ -f docker/arm64/libs/Dockerfile . .PHONY: arm64-build-libs diff --git a/docker/amd64/libs/Dockerfile b/docker/amd64/libs/Dockerfile index 95a3f35..4383c55 100644 --- a/docker/amd64/libs/Dockerfile +++ b/docker/amd64/libs/Dockerfile @@ -1,4 +1,6 @@ -FROM joseluisq/rust-linux-darwin-builder:v2.0.0-beta.1 +ARG BASE_IMAGE=joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 + +FROM ${BASE_IMAGE} # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 diff --git a/docker/arm64/libs/Dockerfile b/docker/arm64/libs/Dockerfile index 8931fcd..8e6f7af 100644 --- a/docker/arm64/libs/Dockerfile +++ b/docker/arm64/libs/Dockerfile @@ -1,4 +1,6 @@ -FROM joseluisq/rust-linux-darwin-builder:v2.0.0-beta.1 +ARG BASE_IMAGE=joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 + +FROM ${BASE_IMAGE} # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 From c1d8430446d0b3c694a3fed597d5728b908e1513 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 00:02:52 +0100 Subject: [PATCH 13/19] chore: join base and libs amd64 ci workflow --- .github/workflows/devel.yml | 568 ++++++++++++++++++++--------------- docker/amd64/libs/Dockerfile | 4 +- 2 files changed, 325 insertions(+), 247 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 52edb97..95d9b37 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -117,143 +117,17 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - docker-arm64: - name: Docker test (arm64) - runs-on: ubuntu-22.04-arm - services: - registry: - image: registry:2 - ports: - - 5000:5000 - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - # https://github.com/actions/runner-images/issues/2840 - - name: Free disk space - run: | - sudo rm -rf /opt/ghc - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf "/usr/local/share/boost" - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: rust-linux-darwin-builder-arm64-buildx-${{ github.sha }} - restore-keys: | - rust-linux-darwin-builder-arm64-buildx- - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKER_IMAGE }} - flavor: | - latest=false - suffix=-arm64 - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - type=raw,value=devel,suffix=-arm64 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver-opts: network=host - - - name: Build and export to Docker client - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - file: docker/arm64/base/Dockerfile - load: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=0.0.0 - push: ${{ github.event_name != 'pull_request' }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - - name: Inspect image - run: | - docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - - name: Check manifest - if: github.event_name != 'pull_request' - run: | - docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - - name: Run tests - uses: addnab/docker-run-action@v3 - with: - image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" - shell: bash - options: -v ${{ github.workspace }}:/root/src - run: | - set -eux - cat /etc/debian_version - uname -a - make test-app - - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - docker-amd64-libs: - needs: - - docker-amd64 - name: Docker test libs (amd64) - runs-on: ubuntu-22.04 - services: - registry: - image: registry:2 - ports: - - 5000:5000 - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - # https://github.com/actions/runner-images/issues/2840 - - name: Free disk space - run: | - sudo rm -rf /opt/ghc - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf "/usr/local/share/boost" - - - name: Cache Docker layers + name: Cache Docker layers (libs) uses: actions/cache@v4 with: - path: /tmp/.buildx-cache + path: /tmp/.buildx-cache2 key: rust-linux-darwin-builder-amd64-libs-buildx-${{ github.sha }} restore-keys: | rust-linux-darwin-builder-amd64-libs-buildx- - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Docker meta - id: meta + name: Docker meta (libs) + id: meta2 uses: docker/metadata-action@v5 with: images: ${{ env.DOCKER_IMAGE }} @@ -269,7 +143,7 @@ jobs: type=semver,pattern={{major}} type=sha - - name: Set up Docker Buildx + name: Set up Docker Buildx (libs) uses: docker/setup-buildx-action@v3 with: driver-opts: network=host @@ -281,28 +155,30 @@ jobs: platforms: linux/amd64 file: docker/amd64/libs/Dockerfile load: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} build-args: | VERSION=0.0.0 - BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-amd64 push: ${{ github.event_name != 'pull_request' }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + cache-from: | + type=local,src=/tmp/.buildx-cache + type=local,src=/tmp/.buildx-cache2 + cache-to: | + type=local,dest=/tmp/.buildx-cache2-new,mode=max - name: Inspect image run: | - docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - name: Check manifest if: github.event_name != 'pull_request' run: | - docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - name: Run tests uses: addnab/docker-run-action@v3 with: - image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" shell: bash options: -v ${{ github.workspace }}:/root/src run: | @@ -318,109 +194,313 @@ jobs: # https://github.com/moby/buildkit/issues/1896 name: Move cache run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + rm -rf /tmp/.buildx-cache2 + mv /tmp/.buildx-cache2-new /tmp/.buildx-cache2 - docker-arm64-libs: - needs: - - docker-arm64 - name: Docker test libs (arm64) - runs-on: ubuntu-22.04-arm - services: - registry: - image: registry:2 - ports: - - 5000:5000 - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - # https://github.com/actions/runner-images/issues/2840 - - name: Free disk space - run: | - sudo rm -rf /opt/ghc - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf "/usr/local/share/boost" - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: rust-linux-darwin-builder-arm64-libs-buildx-${{ github.sha }} - restore-keys: | - rust-linux-darwin-builder-arm64-libs-buildx- - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKER_IMAGE }} - flavor: | - latest=false - suffix=-arm64-libs - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver-opts: network=host - - - name: Build and export to Docker client - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - file: docker/arm64/libs/Dockerfile - load: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=0.0.0 - BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-arm64 - push: ${{ github.event_name != 'pull_request' }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - - name: Inspect image - run: | - docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - - name: Check manifest - if: github.event_name != 'pull_request' - run: | - docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - - name: Run tests - uses: addnab/docker-run-action@v3 - with: - image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" - shell: bash - options: -v ${{ github.workspace }}:/root/src - run: | - set -eux - cat /etc/debian_version - uname -a - make test-app - make test-zlib - make test-openssl - - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + # docker-arm64: + # name: Docker test (arm64) + # runs-on: ubuntu-22.04-arm + # services: + # registry: + # image: registry:2 + # ports: + # - 5000:5000 + # steps: + # - + # name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 1 + # # https://github.com/actions/runner-images/issues/2840 + # - name: Free disk space + # run: | + # sudo rm -rf /opt/ghc + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf /usr/local/lib/android + # sudo rm -rf "/usr/local/share/boost" + # - + # name: Cache Docker layers + # uses: actions/cache@v4 + # with: + # path: /tmp/.buildx-cache + # key: rust-linux-darwin-builder-arm64-buildx-${{ github.sha }} + # restore-keys: | + # rust-linux-darwin-builder-arm64-buildx- + # - + # name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + # - + # name: Docker meta + # id: meta + # uses: docker/metadata-action@v5 + # with: + # images: ${{ env.DOCKER_IMAGE }} + # flavor: | + # latest=false + # suffix=-arm64 + # tags: | + # type=schedule + # type=ref,event=branch + # type=ref,event=pr + # type=semver,pattern={{version}} + # type=semver,pattern={{major}}.{{minor}} + # type=semver,pattern={{major}} + # type=sha + # type=raw,value=devel,suffix=-arm64 + # - + # name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 + # with: + # driver-opts: network=host + # - + # name: Build and export to Docker client + # uses: docker/build-push-action@v6 + # with: + # context: . + # platforms: linux/arm64 + # file: docker/arm64/base/Dockerfile + # load: true + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # build-args: | + # VERSION=0.0.0 + # push: ${{ github.event_name != 'pull_request' }} + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - + # name: Inspect image + # run: | + # docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + # - + # name: Check manifest + # if: github.event_name != 'pull_request' + # run: | + # docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + # - + # name: Run tests + # uses: addnab/docker-run-action@v3 + # with: + # image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + # shell: bash + # options: -v ${{ github.workspace }}:/root/src + # run: | + # set -eux + # cat /etc/debian_version + # uname -a + # make test-app + # - + # # Temp fix + # # https://github.com/docker/build-push-action/issues/252 + # # https://github.com/moby/buildkit/issues/1896 + # name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + # docker-amd64-libs: + # needs: + # - docker-amd64 + # name: Docker test libs (amd64) + # runs-on: ubuntu-22.04 + # services: + # registry: + # image: registry:2 + # ports: + # - 5000:5000 + # steps: + # - + # name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 1 + # # https://github.com/actions/runner-images/issues/2840 + # - name: Free disk space + # run: | + # sudo rm -rf /opt/ghc + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf /usr/local/lib/android + # sudo rm -rf "/usr/local/share/boost" + # - + # name: Cache Docker layers + # uses: actions/cache@v4 + # with: + # path: /tmp/.buildx-cache + # key: rust-linux-darwin-builder-amd64-libs-buildx-${{ github.sha }} + # restore-keys: | + # rust-linux-darwin-builder-amd64-libs-buildx- + # - + # name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + # - + # name: Docker meta + # id: meta + # uses: docker/metadata-action@v5 + # with: + # images: ${{ env.DOCKER_IMAGE }} + # flavor: | + # latest=false + # suffix=-amd64-libs + # tags: | + # type=schedule + # type=ref,event=branch + # type=ref,event=pr + # type=semver,pattern={{version}} + # type=semver,pattern={{major}}.{{minor}} + # type=semver,pattern={{major}} + # type=sha + # - + # name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 + # with: + # driver-opts: network=host + # - + # name: Build and export to Docker client + # uses: docker/build-push-action@v6 + # with: + # context: . + # platforms: linux/amd64 + # file: docker/amd64/libs/Dockerfile + # load: true + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # build-args: | + # VERSION=0.0.0 + # BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-amd64 + # push: ${{ github.event_name != 'pull_request' }} + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - + # name: Inspect image + # run: | + # docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + # - + # name: Check manifest + # if: github.event_name != 'pull_request' + # run: | + # docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + # - + # name: Run tests + # uses: addnab/docker-run-action@v3 + # with: + # image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + # shell: bash + # options: -v ${{ github.workspace }}:/root/src + # run: | + # set -eux + # cat /etc/debian_version + # uname -a + # make test-app + # make test-zlib + # make test-openssl + # - + # # Temp fix + # # https://github.com/docker/build-push-action/issues/252 + # # https://github.com/moby/buildkit/issues/1896 + # name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + # docker-arm64-libs: + # needs: + # - docker-arm64 + # name: Docker test libs (arm64) + # runs-on: ubuntu-22.04-arm + # services: + # registry: + # image: registry:2 + # ports: + # - 5000:5000 + # steps: + # - + # name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 1 + # # https://github.com/actions/runner-images/issues/2840 + # - name: Free disk space + # run: | + # sudo rm -rf /opt/ghc + # sudo rm -rf /usr/share/dotnet + # sudo rm -rf /usr/local/lib/android + # sudo rm -rf "/usr/local/share/boost" + # - + # name: Cache Docker layers + # uses: actions/cache@v4 + # with: + # path: /tmp/.buildx-cache + # key: rust-linux-darwin-builder-arm64-libs-buildx-${{ github.sha }} + # restore-keys: | + # rust-linux-darwin-builder-arm64-libs-buildx- + # - + # name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + # - + # name: Docker meta + # id: meta + # uses: docker/metadata-action@v5 + # with: + # images: ${{ env.DOCKER_IMAGE }} + # flavor: | + # latest=false + # suffix=-arm64-libs + # tags: | + # type=schedule + # type=ref,event=branch + # type=ref,event=pr + # type=semver,pattern={{version}} + # type=semver,pattern={{major}}.{{minor}} + # type=semver,pattern={{major}} + # type=sha + # - + # name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 + # with: + # driver-opts: network=host + # - + # name: Build and export to Docker client + # uses: docker/build-push-action@v6 + # with: + # context: . + # platforms: linux/arm64 + # file: docker/arm64/libs/Dockerfile + # load: true + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # build-args: | + # VERSION=0.0.0 + # BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-arm64 + # push: ${{ github.event_name != 'pull_request' }} + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - + # name: Inspect image + # run: | + # docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + # - + # name: Check manifest + # if: github.event_name != 'pull_request' + # run: | + # docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + # - + # name: Run tests + # uses: addnab/docker-run-action@v3 + # with: + # image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + # shell: bash + # options: -v ${{ github.workspace }}:/root/src + # run: | + # set -eux + # cat /etc/debian_version + # uname -a + # make test-app + # make test-zlib + # make test-openssl + # - + # # Temp fix + # # https://github.com/docker/build-push-action/issues/252 + # # https://github.com/moby/buildkit/issues/1896 + # name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/docker/amd64/libs/Dockerfile b/docker/amd64/libs/Dockerfile index 4383c55..4914dc6 100644 --- a/docker/amd64/libs/Dockerfile +++ b/docker/amd64/libs/Dockerfile @@ -1,6 +1,4 @@ -ARG BASE_IMAGE=joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 - -FROM ${BASE_IMAGE} +FROM joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 From b66a0733db268bd6348fbba5d7d8c75ebbff5a13 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 02:22:06 +0100 Subject: [PATCH 14/19] refactor: use ghcr as cache for docker amd64 --- .github/workflows/devel.yml | 179 +++++++++++++++++------------------- 1 file changed, 85 insertions(+), 94 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 95d9b37..78d3323 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -14,17 +14,12 @@ on: - .github/workflows/*.yml env: - DOCKER_IMAGE: localhost:5000/github.com/joseluisq/rust-linux-darwin-builder + DOCKER_IMAGE: ghcr.io/${{ github.repository }} jobs: docker-amd64: name: Docker test (amd64) runs-on: ubuntu-22.04 - services: - registry: - image: registry:2 - ports: - - 5000:5000 steps: - name: Checkout @@ -34,18 +29,20 @@ jobs: # https://github.com/actions/runner-images/issues/2840 - name: Free disk space run: | - sudo rm -rf /opt/ghc sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf "/usr/local/share/boost" + sudo rm -rf /usr/local/lib/android/sdk/build-tools + sudo rm -rf /usr/local/lib/android/sdk/cmake + sudo rm -rf /usr/local/lib/android/sdk/cmdline-tools + sudo rm -rf /usr/local/lib/android/sdk/extras + sudo rm -rf /usr/local/lib/android/sdk/ndk - - name: Cache Docker layers - uses: actions/cache@v4 + name: Login to ghcr.io + uses: docker/login-action@v3 + # if: github.ref == 'refs/heads/main' with: - path: /tmp/.buildx-cache - key: rust-linux-darwin-builder-amd64-buildx-${{ github.sha }} - restore-keys: | - rust-linux-darwin-builder-amd64-buildx- + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -57,74 +54,67 @@ jobs: images: ${{ env.DOCKER_IMAGE }} flavor: | latest=false - suffix=-amd64 tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - type=raw,value=devel,suffix=-amd64 + type=raw,value=devel-amd64 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - - name: Build and export to Docker client + name: Build image uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64 file: docker/amd64/base/Dockerfile - load: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 - push: ${{ github.event_name != 'pull_request' }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + push: false + load: true + cache-from: type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-amd64,mode=max - name: Inspect image run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - - name: Check manifest - if: github.event_name != 'pull_request' - run: | - docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - name: Run tests uses: addnab/docker-run-action@v3 with: - image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" - shell: bash - options: -v ${{ github.workspace }}:/root/src - run: | - set -eux - cat /etc/debian_version - uname -a - make test-app + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache + name: Build image & push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + file: docker/amd64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + # push: ${{ github.ref == 'refs/heads/master' }} + push: true + cache-from: type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-amd64,mode=max + - + name: Check manifest + # if: github.ref == 'refs/heads/master' run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + + ## Docker AMD64 libs - - - name: Cache Docker layers (libs) - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache2 - key: rust-linux-darwin-builder-amd64-libs-buildx-${{ github.sha }} - restore-keys: | - rust-linux-darwin-builder-amd64-libs-buildx- - name: Docker meta (libs) id: meta2 @@ -133,69 +123,70 @@ jobs: images: ${{ env.DOCKER_IMAGE }} flavor: | latest=false - suffix=-amd64-libs tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha + type=raw,value=devel-libs-amd64 - name: Set up Docker Buildx (libs) uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - - name: Build and export to Docker client + name: Build image (libs) uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64 file: docker/amd64/libs/Dockerfile - load: true tags: ${{ steps.meta2.outputs.tags }} labels: ${{ steps.meta2.outputs.labels }} build-args: | VERSION=0.0.0 - push: ${{ github.event_name != 'pull_request' }} + push: false + load: true cache-from: | - type=local,src=/tmp/.buildx-cache - type=local,src=/tmp/.buildx-cache2 - cache-to: | - type=local,dest=/tmp/.buildx-cache2-new,mode=max + type=gha,scope=devel-libs-amd64 + type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-libs-amd64,mode=max - - name: Inspect image + name: Inspect image (libs) run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - - name: Check manifest - if: github.event_name != 'pull_request' - run: | - docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - - - name: Run tests + name: Run tests (libs) uses: addnab/docker-run-action@v3 with: - image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" - shell: bash - options: -v ${{ github.workspace }}:/root/src - run: | - set -eux - cat /etc/debian_version - uname -a - make test-app - make test-zlib - make test-openssl + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + name: Build image & push (libs) + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + file: docker/amd64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=0.0.0 + # push: ${{ github.ref == 'refs/heads/master' }} + push: true + cache-from: | + type=gha,scope=devel-libs-amd64 + type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-libs-amd64,mode=max - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache + name: Check manifest (libs) + # if: github.ref == 'refs/heads/master' run: | - rm -rf /tmp/.buildx-cache2 - mv /tmp/.buildx-cache2-new /tmp/.buildx-cache2 + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} # docker-arm64: # name: Docker test (arm64) From b52e5c4676f35624f9ba3638aace7faa88c67995 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 02:36:32 +0100 Subject: [PATCH 15/19] refactor: use ghcr as cache for arm64 --- .github/workflows/devel.yml | 477 +++++++++++++----------------------- 1 file changed, 170 insertions(+), 307 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 78d3323..81549d8 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -18,7 +18,7 @@ env: jobs: docker-amd64: - name: Docker test (amd64) + name: Docker test (AMD64) runs-on: ubuntu-22.04 steps: - @@ -113,7 +113,7 @@ jobs: run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - ## Docker AMD64 libs + ## AMD64 libs - name: Docker meta (libs) @@ -188,310 +188,173 @@ jobs: run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - # docker-arm64: - # name: Docker test (arm64) - # runs-on: ubuntu-22.04-arm - # services: - # registry: - # image: registry:2 - # ports: - # - 5000:5000 - # steps: - # - - # name: Checkout - # uses: actions/checkout@v4 - # with: - # fetch-depth: 1 - # # https://github.com/actions/runner-images/issues/2840 - # - name: Free disk space - # run: | - # sudo rm -rf /opt/ghc - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf /usr/local/lib/android - # sudo rm -rf "/usr/local/share/boost" - # - - # name: Cache Docker layers - # uses: actions/cache@v4 - # with: - # path: /tmp/.buildx-cache - # key: rust-linux-darwin-builder-arm64-buildx-${{ github.sha }} - # restore-keys: | - # rust-linux-darwin-builder-arm64-buildx- - # - - # name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - # - - # name: Docker meta - # id: meta - # uses: docker/metadata-action@v5 - # with: - # images: ${{ env.DOCKER_IMAGE }} - # flavor: | - # latest=false - # suffix=-arm64 - # tags: | - # type=schedule - # type=ref,event=branch - # type=ref,event=pr - # type=semver,pattern={{version}} - # type=semver,pattern={{major}}.{{minor}} - # type=semver,pattern={{major}} - # type=sha - # type=raw,value=devel,suffix=-arm64 - # - - # name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # driver-opts: network=host - # - - # name: Build and export to Docker client - # uses: docker/build-push-action@v6 - # with: - # context: . - # platforms: linux/arm64 - # file: docker/arm64/base/Dockerfile - # load: true - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - # build-args: | - # VERSION=0.0.0 - # push: ${{ github.event_name != 'pull_request' }} - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - - # name: Inspect image - # run: | - # docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # - - # name: Check manifest - # if: github.event_name != 'pull_request' - # run: | - # docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # - - # name: Run tests - # uses: addnab/docker-run-action@v3 - # with: - # image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" - # shell: bash - # options: -v ${{ github.workspace }}:/root/src - # run: | - # set -eux - # cat /etc/debian_version - # uname -a - # make test-app - # - - # # Temp fix - # # https://github.com/docker/build-push-action/issues/252 - # # https://github.com/moby/buildkit/issues/1896 - # name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + docker-arm64: + name: Docker test (ARM64) + runs-on: ubuntu-22.04-arm + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android/sdk/build-tools + sudo rm -rf /usr/local/lib/android/sdk/cmake + sudo rm -rf /usr/local/lib/android/sdk/cmdline-tools + sudo rm -rf /usr/local/lib/android/sdk/extras + sudo rm -rf /usr/local/lib/android/sdk/ndk + - + name: Login to ghcr.io + uses: docker/login-action@v3 + # if: github.ref == 'refs/heads/main' + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + flavor: | + latest=false + tags: | + type=raw,value=devel-arm64 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + - + name: Build image + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + push: false + load: true + cache-from: type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-arm64,mode=max + - + name: Inspect image + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Run tests + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + - + name: Build image & push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=0.0.0 + # push: ${{ github.ref == 'refs/heads/master' }} + push: true + cache-from: type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-arm64,mode=max + - + name: Check manifest + # if: github.ref == 'refs/heads/master' + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # docker-amd64-libs: - # needs: - # - docker-amd64 - # name: Docker test libs (amd64) - # runs-on: ubuntu-22.04 - # services: - # registry: - # image: registry:2 - # ports: - # - 5000:5000 - # steps: - # - - # name: Checkout - # uses: actions/checkout@v4 - # with: - # fetch-depth: 1 - # # https://github.com/actions/runner-images/issues/2840 - # - name: Free disk space - # run: | - # sudo rm -rf /opt/ghc - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf /usr/local/lib/android - # sudo rm -rf "/usr/local/share/boost" - # - - # name: Cache Docker layers - # uses: actions/cache@v4 - # with: - # path: /tmp/.buildx-cache - # key: rust-linux-darwin-builder-amd64-libs-buildx-${{ github.sha }} - # restore-keys: | - # rust-linux-darwin-builder-amd64-libs-buildx- - # - - # name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - # - - # name: Docker meta - # id: meta - # uses: docker/metadata-action@v5 - # with: - # images: ${{ env.DOCKER_IMAGE }} - # flavor: | - # latest=false - # suffix=-amd64-libs - # tags: | - # type=schedule - # type=ref,event=branch - # type=ref,event=pr - # type=semver,pattern={{version}} - # type=semver,pattern={{major}}.{{minor}} - # type=semver,pattern={{major}} - # type=sha - # - - # name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # driver-opts: network=host - # - - # name: Build and export to Docker client - # uses: docker/build-push-action@v6 - # with: - # context: . - # platforms: linux/amd64 - # file: docker/amd64/libs/Dockerfile - # load: true - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - # build-args: | - # VERSION=0.0.0 - # BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-amd64 - # push: ${{ github.event_name != 'pull_request' }} - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - - # name: Inspect image - # run: | - # docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # - - # name: Check manifest - # if: github.event_name != 'pull_request' - # run: | - # docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # - - # name: Run tests - # uses: addnab/docker-run-action@v3 - # with: - # image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" - # shell: bash - # options: -v ${{ github.workspace }}:/root/src - # run: | - # set -eux - # cat /etc/debian_version - # uname -a - # make test-app - # make test-zlib - # make test-openssl - # - - # # Temp fix - # # https://github.com/docker/build-push-action/issues/252 - # # https://github.com/moby/buildkit/issues/1896 - # name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + ## ARM64 libs - # docker-arm64-libs: - # needs: - # - docker-arm64 - # name: Docker test libs (arm64) - # runs-on: ubuntu-22.04-arm - # services: - # registry: - # image: registry:2 - # ports: - # - 5000:5000 - # steps: - # - - # name: Checkout - # uses: actions/checkout@v4 - # with: - # fetch-depth: 1 - # # https://github.com/actions/runner-images/issues/2840 - # - name: Free disk space - # run: | - # sudo rm -rf /opt/ghc - # sudo rm -rf /usr/share/dotnet - # sudo rm -rf /usr/local/lib/android - # sudo rm -rf "/usr/local/share/boost" - # - - # name: Cache Docker layers - # uses: actions/cache@v4 - # with: - # path: /tmp/.buildx-cache - # key: rust-linux-darwin-builder-arm64-libs-buildx-${{ github.sha }} - # restore-keys: | - # rust-linux-darwin-builder-arm64-libs-buildx- - # - - # name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - # - - # name: Docker meta - # id: meta - # uses: docker/metadata-action@v5 - # with: - # images: ${{ env.DOCKER_IMAGE }} - # flavor: | - # latest=false - # suffix=-arm64-libs - # tags: | - # type=schedule - # type=ref,event=branch - # type=ref,event=pr - # type=semver,pattern={{version}} - # type=semver,pattern={{major}}.{{minor}} - # type=semver,pattern={{major}} - # type=sha - # - - # name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # driver-opts: network=host - # - - # name: Build and export to Docker client - # uses: docker/build-push-action@v6 - # with: - # context: . - # platforms: linux/arm64 - # file: docker/arm64/libs/Dockerfile - # load: true - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - # build-args: | - # VERSION=0.0.0 - # BASE_IMAGE=${{ env.DOCKER_IMAGE }}:devel-arm64 - # push: ${{ github.event_name != 'pull_request' }} - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - - # name: Inspect image - # run: | - # docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # - - # name: Check manifest - # if: github.event_name != 'pull_request' - # run: | - # docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - # - - # name: Run tests - # uses: addnab/docker-run-action@v3 - # with: - # image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" - # shell: bash - # options: -v ${{ github.workspace }}:/root/src - # run: | - # set -eux - # cat /etc/debian_version - # uname -a - # make test-app - # make test-zlib - # make test-openssl - # - - # # Temp fix - # # https://github.com/docker/build-push-action/issues/252 - # # https://github.com/moby/buildkit/issues/1896 - # name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - + name: Docker meta (libs) + id: meta2 + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + flavor: | + latest=false + tags: | + type=raw,value=devel-libs-arm64 + - + name: Set up Docker Buildx (libs) + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host + - + name: Build image (libs) + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=0.0.0 + push: false + load: true + cache-from: | + type=gha,scope=devel-libs-arm64 + type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-libs-arm64,mode=max + - + name: Inspect image (libs) + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} + - + name: Run tests (libs) + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + name: Build image & push (libs) + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=0.0.0 + # push: ${{ github.ref == 'refs/heads/master' }} + push: true + cache-from: | + type=gha,scope=devel-libs-arm64 + type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-libs-arm64,mode=max + - + name: Check manifest (libs) + # if: github.ref == 'refs/heads/master' + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} From 1b76ebfe91f5b2025b1431596ca3931ef5c38c6e Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 03:01:43 +0100 Subject: [PATCH 16/19] chore: rename workflow steps --- .github/workflows/devel.yml | 78 ++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 81549d8..361b73c 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -18,7 +18,7 @@ env: jobs: docker-amd64: - name: Docker test (AMD64) + name: Docker devel (amd64) runs-on: ubuntu-22.04 steps: - @@ -36,18 +36,17 @@ jobs: sudo rm -rf /usr/local/lib/android/sdk/extras sudo rm -rf /usr/local/lib/android/sdk/ndk - - name: Login to ghcr.io + name: Login uses: docker/login-action@v3 - # if: github.ref == 'refs/heads/main' with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU + name: QEMU uses: docker/setup-qemu-action@v3 - - name: Docker meta + name: Metadata (base) id: meta uses: docker/metadata-action@v5 with: @@ -57,12 +56,12 @@ jobs: tags: | type=raw,value=devel-amd64 - - name: Set up Docker Buildx + name: Setup (base) uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - - name: Build image + name: Build (base) uses: docker/build-push-action@v6 with: context: . @@ -77,11 +76,11 @@ jobs: cache-from: type=gha,scope=devel-amd64 cache-to: type=gha,scope=devel-amd64,mode=max - - name: Inspect image + name: Inspect (base) run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - name: Run tests + name: Tests (base) uses: addnab/docker-run-action@v3 with: image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" @@ -93,7 +92,7 @@ jobs: uname -a make test-app - - name: Build image & push + name: Push (base) uses: docker/build-push-action@v6 with: context: . @@ -103,20 +102,18 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 - # push: ${{ github.ref == 'refs/heads/master' }} push: true cache-from: type=gha,scope=devel-amd64 cache-to: type=gha,scope=devel-amd64,mode=max - - name: Check manifest - # if: github.ref == 'refs/heads/master' + name: Manifest (base) run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} ## AMD64 libs - - name: Docker meta (libs) + name: Metadata (libs) id: meta2 uses: docker/metadata-action@v5 with: @@ -126,12 +123,12 @@ jobs: tags: | type=raw,value=devel-libs-amd64 - - name: Set up Docker Buildx (libs) + name: Setup (libs) uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - - name: Build image (libs) + name: Build (libs) uses: docker/build-push-action@v6 with: context: . @@ -148,11 +145,11 @@ jobs: type=gha,scope=devel-amd64 cache-to: type=gha,scope=devel-libs-amd64,mode=max - - name: Inspect image (libs) + name: Inspect (libs) run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - - name: Run tests (libs) + name: Tests (libs) uses: addnab/docker-run-action@v3 with: image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" @@ -166,7 +163,7 @@ jobs: make test-zlib make test-openssl - - name: Build image & push (libs) + name: Push (libs) uses: docker/build-push-action@v6 with: context: . @@ -176,20 +173,18 @@ jobs: labels: ${{ steps.meta2.outputs.labels }} build-args: | VERSION=0.0.0 - # push: ${{ github.ref == 'refs/heads/master' }} push: true cache-from: | type=gha,scope=devel-libs-amd64 type=gha,scope=devel-amd64 cache-to: type=gha,scope=devel-libs-amd64,mode=max - - name: Check manifest (libs) - # if: github.ref == 'refs/heads/master' + name: Manifest (libs) run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} docker-arm64: - name: Docker test (ARM64) + name: Docker devel (arm64) runs-on: ubuntu-22.04-arm steps: - @@ -207,18 +202,17 @@ jobs: sudo rm -rf /usr/local/lib/android/sdk/extras sudo rm -rf /usr/local/lib/android/sdk/ndk - - name: Login to ghcr.io + name: Login uses: docker/login-action@v3 - # if: github.ref == 'refs/heads/main' with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU + name: QEMU uses: docker/setup-qemu-action@v3 - - name: Docker meta + name: Metadata (base) id: meta uses: docker/metadata-action@v5 with: @@ -228,12 +222,12 @@ jobs: tags: | type=raw,value=devel-arm64 - - name: Set up Docker Buildx + name: Setup (base) uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - - name: Build image + name: Build (base) uses: docker/build-push-action@v6 with: context: . @@ -248,11 +242,11 @@ jobs: cache-from: type=gha,scope=devel-arm64 cache-to: type=gha,scope=devel-arm64,mode=max - - name: Inspect image + name: Inspect (base) run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} - - name: Run tests + name: Tests (base) uses: addnab/docker-run-action@v3 with: image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" @@ -264,7 +258,7 @@ jobs: uname -a make test-app - - name: Build image & push + name: Push (base) uses: docker/build-push-action@v6 with: context: . @@ -274,20 +268,18 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=0.0.0 - # push: ${{ github.ref == 'refs/heads/master' }} push: true cache-from: type=gha,scope=devel-arm64 cache-to: type=gha,scope=devel-arm64,mode=max - - name: Check manifest - # if: github.ref == 'refs/heads/master' + name: Manifest (base) run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} ## ARM64 libs - - name: Docker meta (libs) + name: Metadata (libs) id: meta2 uses: docker/metadata-action@v5 with: @@ -297,12 +289,12 @@ jobs: tags: | type=raw,value=devel-libs-arm64 - - name: Set up Docker Buildx (libs) + name: Setup (libs) uses: docker/setup-buildx-action@v3 with: driver-opts: network=host - - name: Build image (libs) + name: Build (libs) uses: docker/build-push-action@v6 with: context: . @@ -319,11 +311,11 @@ jobs: type=gha,scope=devel-arm64 cache-to: type=gha,scope=devel-libs-arm64,mode=max - - name: Inspect image (libs) + name: Inspect (libs) run: | docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - - name: Run tests (libs) + name: Tests (libs) uses: addnab/docker-run-action@v3 with: image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" @@ -337,7 +329,7 @@ jobs: make test-zlib make test-openssl - - name: Build image & push (libs) + name: Push (libs) uses: docker/build-push-action@v6 with: context: . @@ -347,14 +339,12 @@ jobs: labels: ${{ steps.meta2.outputs.labels }} build-args: | VERSION=0.0.0 - # push: ${{ github.ref == 'refs/heads/master' }} push: true cache-from: | type=gha,scope=devel-libs-arm64 type=gha,scope=devel-arm64 cache-to: type=gha,scope=devel-libs-arm64,mode=max - - name: Check manifest (libs) - # if: github.ref == 'refs/heads/master' + name: Manifest (libs) run: | docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} From bec142857221d1f6aaca1d8891d449622aa1625e Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 12:10:34 +0100 Subject: [PATCH 17/19] chore: add release-beta workflow --- .github/workflows/devel.yml | 2 +- .github/workflows/release-beta.yml | 399 ++++++++++++++++++++++++++--- docker/amd64/base/Dockerfile | 8 +- docker/amd64/libs/Dockerfile | 8 + docker/arm64/base/Dockerfile | 8 +- docker/arm64/libs/Dockerfile | 10 +- 6 files changed, 387 insertions(+), 48 deletions(-) diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 361b73c..766b59f 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -36,7 +36,7 @@ jobs: sudo rm -rf /usr/local/lib/android/sdk/extras sudo rm -rf /usr/local/lib/android/sdk/ndk - - name: Login + name: Login to ghcr.io uses: docker/login-action@v3 with: registry: ghcr.io diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index f17268c..4ebf328 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -4,19 +4,46 @@ on: tags: - 'v2.0.[0-9]+-beta.[0-9]+' +env: + DOCKER_IMAGE: ghcr.io/joseluisq/rust-linux-darwin-builder + jobs: - build-amd64: - name: osxcross (amd64) + docker-amd64: + name: Docker beta release (amd64) runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android/sdk/build-tools + sudo rm -rf /usr/local/lib/android/sdk/cmake + sudo rm -rf /usr/local/lib/android/sdk/cmdline-tools + sudo rm -rf /usr/local/lib/android/sdk/extras + sudo rm -rf /usr/local/lib/android/sdk/ndk + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set up QEMU + name: QEMU uses: docker/setup-qemu-action@v3 - - name: Docker meta + name: Metadata (base) id: meta uses: docker/metadata-action@v5 with: @@ -30,44 +57,171 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{version}}-amd64 - - name: Set up Docker Buildx + name: Setup (base) uses: docker/setup-buildx-action@v3 - - name: Login to ghcr.io - uses: docker/login-action@v3 + name: Build (base) + uses: docker/build-push-action@v6 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + context: . + platforms: linux/amd64 + file: docker/amd64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} + push: false + load: true + cache-from: type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-amd64,mode=max - - name: Login to DockerHub - uses: docker/login-action@v3 + name: Inspect (base) + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Tests (base) + uses: addnab/docker-run-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app - - name: Build and push + name: Push (base) uses: docker/build-push-action@v6 with: + context: . + platforms: linux/amd64 + file: docker/amd64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} push: true provenance: false + cache-from: type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-amd64,mode=max + - + name: Manifest (base) + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + + ## AMD64 libs + + - + name: Metadata (libs) + id: meta2 + uses: docker/metadata-action@v5 + with: + images: | + joseluisq/rust-linux-darwin-builder + ghcr.io/joseluisq/rust-linux-darwin-builder + flavor: | + latest=false + suffix=-libs-amd64 + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{version}}-libs-amd64 + - + name: Setup (libs) + uses: docker/setup-buildx-action@v3 + - + name: Build (libs) + uses: docker/build-push-action@v6 + with: context: . platforms: linux/amd64 - file: ./docker/amd64/base/Dockerfile - tags: ${{ steps.meta.outputs.tags }} + file: docker/amd64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=${{ steps.meta2.outputs.version }} + push: false + load: true + cache-from: | + type=gha,scope=devel-libs-amd64 + type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-libs-amd64,mode=max + - + name: Inspect (libs) + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} + - + name: Tests (libs) + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + name: Push (libs) + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + file: docker/amd64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=${{ steps.meta2.outputs.version }} + push: true + provenance: false + cache-from: | + type=gha,scope=devel-libs-amd64 + type=gha,scope=devel-amd64 + cache-to: type=gha,scope=devel-libs-amd64,mode=max + - + name: Manifest (libs) + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} - build-arm64: - name: osxcross (arm64) + docker-arm64: + name: Docker beta release (arm64) runs-on: ubuntu-22.04-arm steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 1 + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android/sdk/build-tools + sudo rm -rf /usr/local/lib/android/sdk/cmake + sudo rm -rf /usr/local/lib/android/sdk/cmdline-tools + sudo rm -rf /usr/local/lib/android/sdk/extras + sudo rm -rf /usr/local/lib/android/sdk/ndk - - name: Set up QEMU + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: QEMU uses: docker/setup-qemu-action@v3 - - name: Docker meta + name: Metadata (base) id: meta uses: docker/metadata-action@v5 with: @@ -81,38 +235,151 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{version}}-arm64 - - name: Set up Docker Buildx + name: Setup (base) uses: docker/setup-buildx-action@v3 - - name: Login to ghcr.io - uses: docker/login-action@v3 + name: Build (base) + uses: docker/build-push-action@v6 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + context: . + platforms: linux/arm64 + file: docker/arm64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} + push: false + load: true + cache-from: type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-arm64,mode=max - - name: Login to DockerHub - uses: docker/login-action@v3 + name: Inspect (base) + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + - + name: Tests (base) + uses: addnab/docker-run-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app - - name: Build and push + name: Push (base) uses: docker/build-push-action@v6 with: + context: . + platforms: linux/arm64 + file: docker/arm64/base/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} push: true provenance: false + cache-from: type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-arm64,mode=max + - + name: Manifest (base) + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} + + ## ARM64 libs + + - + name: Metadata (libs) + id: meta2 + uses: docker/metadata-action@v5 + with: + images: | + joseluisq/rust-linux-darwin-builder + ghcr.io/joseluisq/rust-linux-darwin-builder + flavor: | + latest=false + suffix=-libs-arm64 + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{version}}-libs-arm64 + - + name: Setup (libs) + uses: docker/setup-buildx-action@v3 + - + name: Build (libs) + uses: docker/build-push-action@v6 + with: context: . platforms: linux/arm64 - file: ./docker/arm64/base/Dockerfile - tags: ${{ steps.meta.outputs.tags }} + file: docker/arm64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=${{ steps.meta2.outputs.version }} + push: false + load: true + cache-from: | + type=gha,scope=devel-libs-arm64 + type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-libs-arm64,mode=max + - + name: Inspect (libs) + run: | + docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} + - + name: Tests (libs) + uses: addnab/docker-run-action@v3 + with: + image: "${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }}" + shell: bash + options: -v ${{ github.workspace }}:/root/src + run: | + set -eux + cat /etc/debian_version + uname -a + make test-app + make test-zlib + make test-openssl + - + name: Push (libs) + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + file: docker/arm64/libs/Dockerfile + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + build-args: | + VERSION=${{ steps.meta2.outputs.version }} + push: true + provenance: false + cache-from: | + type=gha,scope=devel-libs-arm64 + type=gha,scope=devel-arm64 + cache-to: type=gha,scope=devel-libs-arm64,mode=max + - + name: Manifest (libs) + run: | + docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta2.outputs.version }} manifest: + name: Docker beta release (manifest) needs: - - build-amd64 - - build-arm64 + - docker-amd64 + - docker-arm64 runs-on: ubuntu-22.04 steps: + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android/sdk/build-tools + sudo rm -rf /usr/local/lib/android/sdk/cmake + sudo rm -rf /usr/local/lib/android/sdk/cmdline-tools + sudo rm -rf /usr/local/lib/android/sdk/extras + sudo rm -rf /usr/local/lib/android/sdk/ndk - name: Set envs run: | github_ref=${GITHUB_REF#refs/tags/} @@ -137,7 +404,7 @@ jobs: run: | docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 - + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 - @@ -154,3 +421,61 @@ jobs: --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-amd64 \ --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-arm64 docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER + + manifest-libs: + name: Docker beta release (manifest libs) + needs: + - docker-amd64 + - docker-arm64 + runs-on: ubuntu-22.04 + steps: + # https://github.com/actions/runner-images/issues/2840 + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android/sdk/build-tools + sudo rm -rf /usr/local/lib/android/sdk/cmake + sudo rm -rf /usr/local/lib/android/sdk/cmdline-tools + sudo rm -rf /usr/local/lib/android/sdk/extras + sudo rm -rf /usr/local/lib/android/sdk/ndk + - name: Set envs + run: | + github_ref=${GITHUB_REF#refs/tags/} + SEMVER=${github_ref##*v} + echo "SEMVER=${SEMVER}" >> $GITHUB_ENV + echo $SEMVER + - + name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Pull all images + run: | + docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-libs-amd64 + docker pull joseluisq/rust-linux-darwin-builder:$SEMVER-libs-arm64 + + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-libs-amd64 + docker pull ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-libs-arm64 + - + name: Push semver alias + run: | + docker manifest create \ + joseluisq/rust-linux-darwin-builder:$SEMVER-libs \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-libs-amd64 \ + --amend joseluisq/rust-linux-darwin-builder:$SEMVER-libs-arm64 + docker manifest push joseluisq/rust-linux-darwin-builder:$SEMVER-libs + + docker manifest create \ + ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-libs \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-libs-amd64 \ + --amend ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-libs-arm64 + docker manifest push ghcr.io/joseluisq/rust-linux-darwin-builder:$SEMVER-libs diff --git a/docker/amd64/base/Dockerfile b/docker/amd64/base/Dockerfile index 0e79d28..25cc8b5 100644 --- a/docker/amd64/base/Dockerfile +++ b/docker/amd64/base/Dockerfile @@ -1,15 +1,15 @@ FROM joseluisq/docker-osxcross:1.0.0-beta.2 +LABEL version="${VERSION}" \ + description="Docker image for cross-compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + ARG VERSION=0.0.0 ENV VERSION=${VERSION} # Rust stable toolchain ARG TOOLCHAIN=1.87.0 -LABEL version="${VERSION}" \ - description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ - maintainer="Jose Quintana " - RUN set -eux \ && dpkg --add-architecture arm64 \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ diff --git a/docker/amd64/libs/Dockerfile b/docker/amd64/libs/Dockerfile index 4914dc6..b8de10f 100644 --- a/docker/amd64/libs/Dockerfile +++ b/docker/amd64/libs/Dockerfile @@ -1,7 +1,15 @@ FROM joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 +LABEL version="${VERSION}" \ + description="Docker image for cross-compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + +ARG VERSION=0.0.0 +ENV VERSION=${VERSION} + # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 + # Crate-related environment variables ENV LIBZ_SYS_STATIC=1 diff --git a/docker/arm64/base/Dockerfile b/docker/arm64/base/Dockerfile index 590c0a1..00fd260 100644 --- a/docker/arm64/base/Dockerfile +++ b/docker/arm64/base/Dockerfile @@ -1,15 +1,15 @@ FROM joseluisq/docker-osxcross:1.0.0-beta.1 +LABEL version="${VERSION}" \ + description="Docker image for cross-compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + ARG VERSION=0.0.0 ENV VERSION=${VERSION} # Rust stable toolchain ARG TOOLCHAIN=1.87.0 -LABEL version="${VERSION}" \ - description="Use same Docker image for compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ - maintainer="Jose Quintana " - RUN set -eux \ && dpkg --add-architecture amd64 \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ diff --git a/docker/arm64/libs/Dockerfile b/docker/arm64/libs/Dockerfile index 8e6f7af..01a019a 100644 --- a/docker/arm64/libs/Dockerfile +++ b/docker/arm64/libs/Dockerfile @@ -1,9 +1,15 @@ -ARG BASE_IMAGE=joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 +FROM joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 -FROM ${BASE_IMAGE} +LABEL version="${VERSION}" \ + description="Docker image for cross-compiling Rust programs for Linux (musl libc) & macOS (osxcross)." \ + maintainer="Jose Quintana " + +ARG VERSION=0.0.0 +ENV VERSION=${VERSION} # zlib - http://zlib.net/ ARG ZLIB_VERSION=1.3.1 + # Crate-related environment variables ENV LIBZ_SYS_STATIC=1 From aa83b9f9576eabd0d36bbcd73e75216634c05ea6 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 14:18:20 +0100 Subject: [PATCH 18/19] docs: update information about new image --- README.md | 116 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 84c2bd4..dcfb005 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,25 @@ ## Overview -This is a __Linux Docker image__ based on [ekidd/rust-musl-builder](https://hub.docker.com/r/ekidd/rust-musl-builder) but using the latest __Debian [12-slim](https://hub.docker.com/_/debian/tags?page=1&name=12-slim)__ ([Bookworm](https://www.debian.org/News/2023/20230610)). +This is a __Linux [multi-arch](https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/) Docker image__ based on the latest __Debian [13-slim](https://hub.docker.com/_/debian/tags?page=1&name=13-slim)__ ([Trixie](https://www.debian.org/News/2025/20250809)). -It contains essential tools for cross-compile [Rust](https://www.rust-lang.org/) projects such as __Linux__ static binaries via [musl-libc / musl-gcc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html) (`x86_64-unknown-linux-musl`) and __macOS__ binaries (`x86_64-apple-darwin`) via [osxcross](https://github.com/tpoechtrager/osxcross) just using the same Linux image. +It contains essential tools for cross-compiling [Rust](https://www.rust-lang.org/) projects such as __Linux__ static binaries via [musl-libc / musl-gcc](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html) (`x86_64-unknown-linux-musl`) and __macOS__ binaries (`x86_64-apple-darwin`) via [osxcross](https://github.com/tpoechtrager/osxcross) just using the same Linux image. -The Docker image is [multi-arch](https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/) (`amd64` and `arm64`) so you can use them in native environments. -Also, it is possible to cross-compile `arm64` Linux or Darwin apps from the `x86_64` Docker image variant. +Additionally, Rust programs can cross-compile for different targets, either from the `linux/arm64` or the `linux/amd64` Docker image variant, so users can take advantage of them in native environments. + +## Supported targets + +__linux/amd64__ + +- `x86_64-apple-darwin` +- `x86_64-unknown-linux-musl` +- `x86_64-unknown-linux-gnu` + +__linux/arm64__ + +- `aarch64-apple-darwin` +- `aarch64-unknown-linux-gnu` +- `aarch64-unknown-linux-musl` ## Usage @@ -42,7 +55,7 @@ Below are the default toolchains included in the Docker image. docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ sh -c "cargo build --release --target x86_64-unknown-linux-musl" ``` @@ -52,7 +65,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ sh -c "cargo build --release --target x86_64-unknown-linux-gnu" ``` @@ -62,7 +75,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ sh -c "cargo build --release --target x86_64-apple-darwin" ``` @@ -74,7 +87,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ sh -c "cargo build --release --target aarch64-unknown-linux-gnu" ``` @@ -84,7 +97,7 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ sh -c "cargo build --release --target aarch64-unknown-linux-musl" ``` @@ -94,44 +107,38 @@ docker run --rm \ docker run --rm \ --volume "${PWD}/sample":/root/src \ --workdir /root/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ + # or \ + # joseluisq/rust-linux-darwin-builder:2.0.0-beta.1-libs \ sh -c "cargo build --release --target aarch64-apple-darwin" ``` -### Cargo Home advice - -It's known that the [`CARGO_HOME`](https://doc.rust-lang.org/cargo/guide/cargo-home.html#cargo-home) points to `$HOME/.cargo` by default (`/root/.cargo` in this case). However, if you want to use a custom Cargo home directory then make sure to copy the Cargo `config` file to the particular directory like `cp "$HOME/.cargo/config" "$CARGO_HOME/"` before to cross-compile your program. Otherwise, you could face a linking error when for example you want to cross-compile to an `x86_64-apple-darwin` target. +### Docker Images -### Dockerfile +You can also use the image as a base for your `Dockerfile`: -You can also use the image as a base for your Dockerfile: +#### Rust toolchains (default image) ```Dockerfile -FROM joseluisq/rust-linux-darwin-builder:1.87.0 +FROM joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 +# or +FROM ghcr.io/joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 ``` -### OSXCross - -You can also use o32-clang(++) and o64-clang(++) as a normal compiler. - -__Notes:__ - -- The current *11.3 SDK* does not support i386 anymore. Use <= 10.13 SDK if you rely on i386 support. -- The current *11.3 SDK* does not support libstdc++ anymore. Use <= 10.13 SDK if you rely on libstdc++ support. +#### Rust toolchains with extra C libraries (optional image) -Examples: +If you need extra C libraries for your Rust project (e.g., OpenSSL or Zlib), you can use the `-libs` variant. -```sh -Example usage: +Built-in C libraries: -Example 1: CC=o32-clang ./configure --host=i386-apple-darwin22.4 -Example 2: CC=i386-apple-darwin22.4-clang ./configure --host=i386-apple-darwin22.4 -Example 3: o64-clang -Wall test.c -o test -Example 4: x86_64-apple-darwin22.4-strip -x test +- **ZLib** `1.3.1` +- **OpenSSL** `3.5.4` +- **libpq** `15.6` (in progress) -!!! Use aarch64-apple-darwin22.4-* instead of arm64-* when dealing with Automake !!! -!!! CC=aarch64-apple-darwin22.4-clang ./configure --host=aarch64-apple-darwin22.4 !!! -!!! CC="aarch64-apple-darwin22.4-clang -arch arm64e" ./configure --host=aarch64-apple-darwin22.4 !!! +```Dockerfile +FROM joseluisq/rust-linux-darwin-builder:2.0.0-beta.1-libs +# or +FROM ghcr.io/joseluisq/rust-linux-darwin-builder:2.0.0-beta.1-libs ``` ### Cross-compilation example @@ -150,7 +157,7 @@ compile: @docker run --rm -it \ -v $(PWD):/app/src \ -w /app/src \ - joseluisq/rust-linux-darwin-builder:1.87.0 \ + joseluisq/rust-linux-darwin-builder:2.0.0-beta.1 \ make cross-compile .PHONY: compile @@ -190,11 +197,7 @@ Just run the makefile `compile` target, then you will see two release binaries ` # 240K tests/hello-world/target/x86_64-apple-darwin/release/helloworld ``` -For more details take a look at [Cross-compiling Rust from Linux to macOS](https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html) by James Waples. - -### Macos ARM64 - -See [joseluisq/rust-linux-darwin-builder#7](https://github.com/joseluisq/rust-linux-darwin-builder/issues/7) +For more examples, take a look at our test suite in [Makefile](./Makefile) and [tests/](./tests/) folder. ### Building *-sys crates @@ -203,6 +206,7 @@ If some of your crates require C bindings and you run into a compilation or link For example to cross-compile to Macos: ```sh +# Note the environment variables CC and CXX CC=o64-clang \ CXX=o64-clang++ \ cargo build --target x86_64-apple-darwin @@ -210,11 +214,35 @@ CXX=o64-clang++ \ cargo build --target aarch64-apple-darwin ``` -### OpenSSL release advice +### Cargo Home advice + +It's known that the [`CARGO_HOME`](https://doc.rust-lang.org/cargo/guide/cargo-home.html#cargo-home) points to `$HOME/.cargo` by default (`/root/.cargo` in this case). However, if you want to use a custom Cargo home directory then make sure to copy the Cargo `config.toml` file to the particular directory like `cp "$HOME/.cargo/config.toml" "$CARGO_HOME/"` before to cross-compile your program. Otherwise, you could face a linking error when for example you want to cross-compile to an `x86_64-apple-darwin` target. + +For more details take a look at [Cross-compiling Rust from Linux to macOS](https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html) by James Waples. + +### OSXCross + +You can also use o32-clang(++) and o64-clang(++) as a normal compiler. + +__Notes:__ + +- The current *11.3 SDK* does not support i386 anymore. Use <= 10.13 SDK if you rely on i386 support. +- The current *11.3 SDK* does not support libstdc++ anymore. Use <= 10.13 SDK if you rely on libstdc++ support. + +Examples: + +```sh +Example usage: + +Example 1: CC=o32-clang ./configure --host=i386-apple-darwin22.4 +Example 2: CC=i386-apple-darwin22.4-clang ./configure --host=i386-apple-darwin22.4 +Example 3: o64-clang -Wall test.c -o test +Example 4: x86_64-apple-darwin22.4-strip -x test -> _Until `v1.42.0` of this project, one old OpenSSL release `v1.0.2` was used._
-> _Now, since `v1.43.x` or greater, OpenSSL `v1.1.1` (LTS) is used which is supported until `2023-09-11`.
-> View more at https://www.openssl.org/policies/releasestrat.html._ +!!! Use aarch64-apple-darwin22.4-* instead of arm64-* when dealing with Automake !!! +!!! CC=aarch64-apple-darwin22.4-clang ./configure --host=aarch64-apple-darwin22.4 !!! +!!! CC="aarch64-apple-darwin22.4-clang -arch arm64e" ./configure --host=aarch64-apple-darwin22.4 !!! +``` ## Contributions From 747fd04f5a19a66202c4f37b0d5ac222b1aa8596 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 31 Oct 2025 14:25:13 +0100 Subject: [PATCH 19/19] chore: restrict devel workflow and remove unused files --- .github/workflows/devel.yml | 6 ++++-- scripts/get-latest-release | 18 ------------------ 2 files changed, 4 insertions(+), 20 deletions(-) delete mode 100755 scripts/get-latest-release diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 766b59f..15eb54a 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -1,16 +1,18 @@ name: devel on: pull_request: - branches: - - master paths: - docker/** + - tests/** + - Makefile - .github/workflows/*.yml push: branches: - master paths: - docker/** + - tests/** + - Makefile - .github/workflows/*.yml env: diff --git a/scripts/get-latest-release b/scripts/get-latest-release deleted file mode 100755 index a2499c8..0000000 --- a/scripts/get-latest-release +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -echo "Getting latest release number..." - -curl \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - "https://api.github.com/repos/joseluisq/rust-linux-darwin-builder/releases?per_page=5&page=1" | \ -jq -c "[ .[] | select( .tag_name | contains(\"v2.\")) ] | .[0]" | \ -jq -r ".tag_name" > /tmp/version - -version=$(cat /tmp/version) - -echo "VERSION=${version#*v}" > /tmp/version - -echo "Version saved on '/tmp/version'"