From 87cbcaa47fc52be03d7f6763e5d2142dc7d350a1 Mon Sep 17 00:00:00 2001 From: Hemna Date: Thu, 15 Dec 2022 13:05:22 -0500 Subject: [PATCH] Try and fix broken 32bit qemu builds on 64bit system This patch adds a 'fix' for trying to build on armv7 32bit system from a 64bit system. qemu seems broken in this case. --- .github/workflows/master-build.yml | 1 + .github/workflows/release_build.yml | 3 ++- docker/Dockerfile | 9 +++++++++ docker/Dockerfile-dev | 9 +++++++++ docker/build.sh | 5 ++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master-build.yml b/.github/workflows/master-build.yml index 8ef5f72..01edc11 100644 --- a/.github/workflows/master-build.yml +++ b/.github/workflows/master-build.yml @@ -56,6 +56,7 @@ jobs: file: ./Dockerfile-dev build-args: | BRANCH=${{ steps.branch-name.outputs.current_branch }} + BUILDX_QEMU_ENV=true push: true tags: | hemna6969/aprsd:${{ steps.branch-name.outputs.current_branch }} diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 7df258f..b6b3f0d 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -39,10 +39,11 @@ jobs: uses: docker/build-push-action@v3 with: context: "{{defaultContext}}:docker" - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/arm/v7 file: ./Dockerfile build-args: | VERSION=${{ inputs.aprsd_version }} + BUILDX_QEMU_ENV=true push: true tags: | hemna6969/aprsd:v${{ inputs.aprsd_version }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 34d9b08..ec8109a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,6 +7,7 @@ ARG UID ARG GID ARG TZ ARG VERSION=2.6.0 +ARG BUILDX_QEMU_ENV ENV APRS_USER=aprs ENV HOME=/home/aprs ENV TZ=${TZ:-US/Eastern} @@ -26,6 +27,14 @@ RUN apt install -y python3 python3-pip python3-dev python3-lxml RUN addgroup --gid $GID $APRS_USER RUN useradd -m -u $UID -g $APRS_USER $APRS_USER +# Handle an extremely specific issue when building the cryptography package for +# 32-bit architectures within QEMU running on a 64-bit host (issue #30). +RUN if [ "${BUILDX_QEMU_ENV}" = "true" -a "$(getconf LONG_BIT)" = "32" ]; then \ + pip3 install -U cryptography==3.3.2; \ + else \ + pip3 install cryptography ;\ + fi + # Install aprsd RUN pip install aprsd==$APRSD_PIP_VERSION diff --git a/docker/Dockerfile-dev b/docker/Dockerfile-dev index a9cb3cf..f1a9dc0 100644 --- a/docker/Dockerfile-dev +++ b/docker/Dockerfile-dev @@ -6,6 +6,8 @@ ARG BRANCH=master ARG UID ARG GID +ARG BUILDX_QEMU_ENV + ENV APRS_USER=aprs ENV HOME=/home/aprs ENV APRSD=http://github.com/craigerl/aprsd.git @@ -39,6 +41,13 @@ RUN cat $HOME/.bashrc USER root WORKDIR $HOME +# Handle an extremely specific issue when building the cryptography package for +# 32-bit architectures within QEMU running on a 64-bit host (issue #30). +RUN if [ "${BUILDX_QEMU_ENV}" = "true" -a "$(getconf LONG_BIT)" = "32" ]; then \ + pip3 install -U cryptography==3.3.2; \ + else \ + pip3 install cryptography ;\ + fi RUN mkdir $INSTALL RUN git clone -b $BRANCH $APRSD $INSTALL/aprsd RUN cd $INSTALL/aprsd && pip3 install -v . diff --git a/docker/build.sh b/docker/build.sh index d68f787..5cc3f9c 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -88,12 +88,15 @@ then # Use this script to locally build the docker image docker buildx build --push --platform $PLATFORMS \ -t harbor.hemna.com/hemna6969/aprsd:$TAG \ - -f Dockerfile-dev --build-arg branch=$BRANCH --no-cache . + -f Dockerfile-dev --build-arg branch=$BRANCH \ + --build-arg BUILDX_QEMU_ENV=true \ + --no-cache . else # Use this script to locally build the docker image echo "Build with tag=${TAG} BRANCH=${BRANCH} dev?=${DEV} platforms?=${PLATFORMS} VERSION=${VERSION}" docker buildx build --push --platform $PLATFORMS \ --build-arg VERSION=$VERSION \ + --build-arg BUILDX_QEMU_ENV=true \ -t hemna6969/aprsd:$VERSION \ -t hemna6969/aprsd:$TAG \ -t hemna6969/aprsd:latest \