From 8c5834c297ce836bf0ad2fd18407654ae614c946 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 30 May 2023 15:47:40 +0200 Subject: docker: fix armhf builds --- Makefile | 2 ++ docker/Dockerfile | 21 ++++++++++++++++++++- test/integration/docker/test.sh | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2fd5e2a..07322c9 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,8 @@ PROJECT := cgitize PLATFORMS := amd64,armhf,arm64 # Docker Hub credentials: DOCKER_USERNAME := egortensin +# This is still required with older Compose versions to use TARGETARCH: +export DOCKER_BUILDKIT := 1 ifdef DOCKER_PASSWORD $(eval $(call noexpand,DOCKER_PASSWORD)) diff --git a/docker/Dockerfile b/docker/Dockerfile index 18bffde..46a2215 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,28 @@ FROM python:3.11-alpine AS base -FROM base AS build +FROM base AS deps RUN apk add -q --no-cache gcc libffi-dev make musl-dev +FROM deps as deps-amd64 +FROM deps as deps-arm64 + +FROM deps as deps-arm + +# The cryptography package doesn't distribute pre-built binaries for this +# platform, which is why it's built manually (and requires extra dependencies). +RUN apk add -q --no-cache cargo git openssl-dev rust + +# Unless this is set, cargo build fails with out of memory errors for some +# reason. Reference: +# +# https://github.com/docker/buildx/issues/359#issuecomment-1331443419 +# +# This is also the reason to install git as a build dependency. +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true + +FROM deps-$TARGETARCH as build + COPY ["requirements.txt", "/tmp/"] RUN pip3 install -q --no-cache-dir --target=/deps -r /tmp/requirements.txt diff --git a/test/integration/docker/test.sh b/test/integration/docker/test.sh index 7cb02a0..d5a7c79 100755 --- a/test/integration/docker/test.sh +++ b/test/integration/docker/test.sh @@ -9,6 +9,9 @@ readonly script_dir script_name="$( basename -- "${BASH_SOURCE[0]}" )" readonly script_name +# This is still required with older Compose versions to use TARGETARCH: +export DOCKER_BUILDKIT=1 + readonly ssh_dir="$script_dir/ssh" readonly client_key_password='password' readonly output_dir="$script_dir/cgitize/output" -- cgit v1.2.3