diff --git a/Dockerfile.alpine-musl b/Dockerfile.alpine-musl index c1988e8..890e0cc 100644 --- a/Dockerfile.alpine-musl +++ b/Dockerfile.alpine-musl @@ -8,41 +8,58 @@ FROM alpine:3.19 AS builder # Re-declare build argument in this stage ARG DEBUG_BUILD=false -# Install build dependencies -RUN apk add --no-cache \ - build-base \ - musl-dev \ - git \ - cmake \ - pkgconfig \ - autoconf \ - automake \ - libtool \ - openssl-dev \ - openssl-libs-static \ - zlib-dev \ - zlib-static \ - curl-dev \ - curl-static \ - nghttp2-dev \ - nghttp2-static \ - c-ares-dev \ - c-ares-static \ - libpsl-dev \ - libpsl-static \ - libidn2-dev \ - libidn2-static \ - libunistring-dev \ - libunistring-static \ - brotli-dev \ - brotli-static \ - zstd-dev \ - zstd-static \ - sqlite-dev \ - sqlite-static \ - linux-headers \ - wget \ - bash +# Install build dependencies (with retry logic for transient mirror/network failures) +RUN set -eux; \ + printf '%s\n' \ + 'https://dl-cdn.alpinelinux.org/alpine/v3.19/main' \ + 'https://dl-cdn.alpinelinux.org/alpine/v3.19/community' \ + > /etc/apk/repositories; \ + APK_OK=0; \ + for attempt in 1 2 3 4 5; do \ + if apk update && apk add --no-cache \ + build-base \ + musl-dev \ + git \ + cmake \ + pkgconfig \ + autoconf \ + automake \ + libtool \ + openssl-dev \ + openssl-libs-static \ + zlib-dev \ + zlib-static \ + curl-dev \ + curl-static \ + nghttp2-dev \ + nghttp2-static \ + c-ares-dev \ + c-ares-static \ + libpsl-dev \ + libpsl-static \ + libidn2-dev \ + libidn2-static \ + libunistring-dev \ + libunistring-static \ + brotli-dev \ + brotli-static \ + zstd-dev \ + zstd-static \ + sqlite-dev \ + sqlite-static \ + linux-headers \ + wget \ + bash; then \ + APK_OK=1; \ + break; \ + fi; \ + echo "apk dependency install failed (attempt ${attempt}/5), retrying..."; \ + sleep $((attempt * 2)); \ + done; \ + if [ "$APK_OK" -ne 1 ]; then \ + echo "ERROR: failed to install Alpine dependencies after 5 attempts"; \ + exit 33; \ + fi # Set working directory WORKDIR /build diff --git a/README.md b/README.md index 8757fbe..1e25b00 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ Skills compose by adoption-list order (`10123`) and trigger tags carry runtime e Didactyl will support local inference, which is very privacy preserving. Remote inference does however have it's advantages, and in those cases Didactyl supports using Bitcoin Lightning and eCash inference providers. -## Current Status — v0.0.88 +## Current Status — v0.0.89 **Active build — this project is barely working. Experiment at your own risk.** -> Last release update: v0.0.88 — Add full static ARM64 build support for didactyl and c-relay with dynamic nostr lib resolution and --platform override +> Last release update: v0.0.89 — Fix and validate fully static ARM64 Docker builds for didactyl and c-relay with reliable cross-arch context and toolchain handling - Connects to configured relays with auto-reconnect and relay state transition logging - Publishes configured startup events per relay as each relay becomes connected diff --git a/build_static.sh b/build_static.sh index d586aee..f41a996 100755 --- a/build_static.sh +++ b/build_static.sh @@ -121,6 +121,34 @@ echo "Building for platform: $PLATFORM" echo "Output binary: $OUTPUT_NAME" echo "" +# Verify Docker can execute the requested target platform (QEMU/binfmt for cross-arch) +HOST_ARCH=$(uname -m) +case "$HOST_ARCH" in + x86_64) HOST_PLATFORM="linux/amd64" ;; + aarch64|arm64) HOST_PLATFORM="linux/arm64" ;; + armv7l) HOST_PLATFORM="linux/arm/v7" ;; + armv6l) HOST_PLATFORM="linux/arm/v6" ;; + *) HOST_PLATFORM="unknown" ;; +esac + +if [ "$HOST_PLATFORM" != "$PLATFORM" ]; then + echo "Cross-architecture build detected: host=$HOST_PLATFORM target=$PLATFORM" + echo "Checking Docker emulation support for $PLATFORM..." + if ! $DOCKER_CMD run --rm --platform "$PLATFORM" alpine:3.19 uname -m > /dev/null 2>&1; then + echo "" + echo "ERROR: Docker cannot execute $PLATFORM containers on this host" + echo "This usually means QEMU/binfmt is not configured." + echo "Run this once, then retry:" + echo " docker run --rm --privileged multiarch/qemu-user-static --reset -p yes" + echo "Optional verify command:" + echo " docker run --rm --platform $PLATFORM alpine:3.19 uname -m" + echo "" + exit 1 + fi + echo "✓ Docker emulation for $PLATFORM is available" + echo "" +fi + # Check if Alpine base image is cached echo "Checking for cached Alpine Docker image..." if ! docker images alpine:3.19 --format "{{.Repository}}:{{.Tag}}" | grep -q "alpine:3.19"; then @@ -150,6 +178,7 @@ echo " - Compile didactyl with full static linking" echo "" $DOCKER_CMD build \ + --network host \ --platform "$PLATFORM" \ --build-arg DEBUG_BUILD=$DEBUG_BUILD \ -f "$DOCKERFILE" \ diff --git a/didactyl_static_arm64 b/didactyl_static_arm64 new file mode 100755 index 0000000..0afc013 Binary files /dev/null and b/didactyl_static_arm64 differ diff --git a/src/main.h b/src/main.h index 37a8e97..2a8c730 100644 --- a/src/main.h +++ b/src/main.h @@ -12,8 +12,8 @@ // Using DIDACTYL_ prefix to avoid conflicts with nostr_core_lib VERSION macros #define DIDACTYL_VERSION_MAJOR 0 #define DIDACTYL_VERSION_MINOR 0 -#define DIDACTYL_VERSION_PATCH 88 -#define DIDACTYL_VERSION "v0.0.88" +#define DIDACTYL_VERSION_PATCH 89 +#define DIDACTYL_VERSION "v0.0.89" // Agent metadata #define DIDACTYL_NAME "Didactyl"