dist: faster builds for ARM and ARM64

We're moving from very slow QEMU-virtualised builds to very fast ones
based on cross toolchains.

- refactor jobs; add checksums to release note
- build and publish Docker images with ARM/ARM64 binaries
This commit is contained in:
Ștefan Talpalaru 2021-03-10 03:59:19 +01:00 committed by zah
parent 12e15a0b8d
commit eafe694536
12 changed files with 241 additions and 216 deletions

View File

@ -10,16 +10,6 @@ jobs:
name: Linux AMD64 release asset name: Linux AMD64 release asset
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build project - name: Build project
@ -27,16 +17,22 @@ jobs:
run: | run: |
make dist-amd64 make dist-amd64
cd dist cd dist
echo "::set-output name=linux_amd64_archive::"$(echo nimbus-eth2_Linux_amd64_*.tar.gz) ARCHIVE=$(echo nimbus-eth2_Linux_amd64_*.tar.gz)
- name: Upload release asset echo "::set-output name=archive::"${ARCHIVE}
uses: actions/upload-release-asset@v1 echo "::set-output name=archive_dir::"${ARCHIVE%.tar.gz}
env: tar -xzf ${ARCHIVE} ${ARCHIVE%.tar.gz}/build/nimbus_beacon_node.sha512sum
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload archive artefact
uses: actions/upload-artifact@v2
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} name: Linux_amd64_archive
asset_path: ./dist/${{ steps.make_dist.outputs.linux_amd64_archive }} path: ./dist/${{ steps.make_dist.outputs.archive }}
asset_name: ${{ steps.make_dist.outputs.linux_amd64_archive }} retention-days: 2
asset_content_type: application/gzip - name: Upload checksum artefact
uses: actions/upload-artifact@v2
with:
name: Linux_amd64_checksum
path: ./dist/${{ steps.make_dist.outputs.archive_dir }}/build/nimbus_beacon_node.sha512sum
retention-days: 2
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
@ -45,8 +41,8 @@ jobs:
- name: Build and push a Docker image for end users - name: Build and push a Docker image for end users
run: | run: |
cd dist cd dist
tar -xzf ${{ steps.make_dist.outputs.linux_amd64_archive }} tar -xzf ${{ steps.make_dist.outputs.archive }}
mv nimbus-eth2_Linux_amd64_*/ ../docker/dist/binaries/nimbus-eth2 mv ${{ steps.make_dist.outputs.archive_dir }} ../docker/dist/binaries/nimbus-eth2
cd ../docker/dist/binaries cd ../docker/dist/binaries
REFNAME="${{ github.ref }}" REFNAME="${{ github.ref }}"
TAG="${REFNAME#refs/tags/}" TAG="${REFNAME#refs/tags/}"
@ -71,25 +67,39 @@ jobs:
run: | run: |
make dist-arm64 make dist-arm64
cd dist cd dist
echo "::set-output name=linux_arm64_archive::"$(echo nimbus-eth2_Linux_arm64v8_*.tar.gz) ARCHIVE=$(echo nimbus-eth2_Linux_arm64v8_*.tar.gz)
- name: Fetch latest release echo "::set-output name=archive::"${ARCHIVE}
id: fetch_release echo "::set-output name=archive_dir::"${ARCHIVE%.tar.gz}
uses: InsonusK/get-latest-release@v1.0.1 tar -xzf ${ARCHIVE} ${ARCHIVE%.tar.gz}/build/nimbus_beacon_node.sha512sum
- name: Upload archive artefact
uses: actions/upload-artifact@v2
with: with:
myToken: ${{ github.token }} name: Linux_arm64_archive
view_top: 1 path: ./dist/${{ steps.make_dist.outputs.archive }}
- name: Check release version retention-days: 2
- name: Upload checksum artefact
uses: actions/upload-artifact@v2
with:
name: Linux_arm64_checksum
path: ./dist/${{ steps.make_dist.outputs.archive_dir }}/build/nimbus_beacon_node.sha512sum
retention-days: 2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push a Docker image for end users
run: | run: |
[[ "refs/tags/${{ steps.fetch_release.outputs.tag_name }}" == "${{ github.ref }}" ]] cd dist
- name: Upload release asset tar -xzf ${{ steps.make_dist.outputs.archive }}
uses: actions/upload-release-asset@v1 mv ${{ steps.make_dist.outputs.archive_dir }} ../docker/dist/binaries/nimbus-eth2
env: cd ../docker/dist/binaries
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REFNAME="${{ github.ref }}"
with: TAG="${REFNAME#refs/tags/}"
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.fetch_release.outputs.id }}/assets{?name,label} cp -a /usr/bin/qemu-aarch64-static .
asset_path: ./dist/${{ steps.make_dist.outputs.linux_arm64_archive }} DOCKER_BUILDKIT=1 docker build -f Dockerfile.arm64 -t statusim/nimbus-eth2:arm64-${TAG} -t statusim/nimbus-eth2:arm64-latest .
asset_name: ${{ steps.make_dist.outputs.linux_arm64_archive }} docker push statusim/nimbus-eth2:arm64-${TAG}
asset_content_type: application/gzip docker push statusim/nimbus-eth2:arm64-latest
build-arm: build-arm:
name: Linux ARM release asset name: Linux ARM release asset
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -108,25 +118,39 @@ jobs:
run: | run: |
make dist-arm make dist-arm
cd dist cd dist
echo "::set-output name=linux_arm_archive::"$(echo nimbus-eth2_Linux_arm32v7_*.tar.gz) ARCHIVE=$(echo nimbus-eth2_Linux_arm32v7_*.tar.gz)
- name: Fetch latest release echo "::set-output name=archive::"${ARCHIVE}
id: fetch_release echo "::set-output name=archive_dir::"${ARCHIVE%.tar.gz}
uses: InsonusK/get-latest-release@v1.0.1 tar -xzf ${ARCHIVE} ${ARCHIVE%.tar.gz}/build/nimbus_beacon_node.sha512sum
- name: Upload archive artefact
uses: actions/upload-artifact@v2
with: with:
myToken: ${{ github.token }} name: Linux_arm_archive
view_top: 1 path: ./dist/${{ steps.make_dist.outputs.archive }}
- name: Check release version retention-days: 2
- name: Upload checksum artefact
uses: actions/upload-artifact@v2
with:
name: Linux_arm_checksum
path: ./dist/${{ steps.make_dist.outputs.archive_dir }}/build/nimbus_beacon_node.sha512sum
retention-days: 2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push a Docker image for end users
run: | run: |
[[ "refs/tags/${{ steps.fetch_release.outputs.tag_name }}" == "${{ github.ref }}" ]] cd dist
- name: Upload release asset tar -xzf ${{ steps.make_dist.outputs.archive }}
uses: actions/upload-release-asset@v1 mv ${{ steps.make_dist.outputs.archive_dir }} ../docker/dist/binaries/nimbus-eth2
env: cd ../docker/dist/binaries
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REFNAME="${{ github.ref }}"
with: TAG="${REFNAME#refs/tags/}"
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.fetch_release.outputs.id }}/assets{?name,label} cp -a /usr/bin/qemu-arm-static .
asset_path: ./dist/${{ steps.make_dist.outputs.linux_arm_archive }} DOCKER_BUILDKIT=1 docker build -f Dockerfile.arm -t statusim/nimbus-eth2:arm-${TAG} -t statusim/nimbus-eth2:arm-latest .
asset_name: ${{ steps.make_dist.outputs.linux_arm_archive }} docker push statusim/nimbus-eth2:arm-${TAG}
asset_content_type: application/gzip docker push statusim/nimbus-eth2:arm-latest
build-win64: build-win64:
name: Windows AMD64 release asset name: Windows AMD64 release asset
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -138,23 +162,72 @@ jobs:
run: | run: |
make dist-win64 make dist-win64
cd dist cd dist
echo "::set-output name=windows_amd64_archive::"$(echo nimbus-eth2_Windows_amd64_*.tar.gz) ARCHIVE=$(echo nimbus-eth2_Windows_amd64_*.tar.gz)
- name: Fetch latest release echo "::set-output name=archive::"${ARCHIVE}
id: fetch_release echo "::set-output name=archive_dir::"${ARCHIVE%.tar.gz}
uses: InsonusK/get-latest-release@v1.0.1 tar -xzf ${ARCHIVE} ${ARCHIVE%.tar.gz}/build/nimbus_beacon_node.sha512sum
- name: Upload archive artefact
uses: actions/upload-artifact@v2
with: with:
myToken: ${{ github.token }} name: Windows_amd64_archive
view_top: 1 path: ./dist/${{ steps.make_dist.outputs.archive }}
- name: Check release version retention-days: 2
- name: Upload checksum artefact
uses: actions/upload-artifact@v2
with:
name: Windows_amd64_checksum
path: ./dist/${{ steps.make_dist.outputs.archive_dir }}/build/nimbus_beacon_node.sha512sum
retention-days: 2
prepare-release:
name: Prepare release draft
needs: [build-amd64, build-arm64, build-arm, build-win64]
runs-on: ubuntu-latest
steps:
- name: Download artefacts
uses: actions/download-artifact@v2
- name: Create release notes
run: | run: |
[[ "refs/tags/${{ steps.fetch_release.outputs.tag_name }}" == "${{ github.ref }}" ]] cat > release_notes.md <<EOF
- name: Upload release asset ## Notes
uses: actions/upload-release-asset@v1
## SHA512 checksums
\`\`\`text
EOF
echo '# Linux AMD64' >> release_notes.md
cat Linux_amd64_checksum/* >> release_notes.md
echo '# Linux ARM64' >> release_notes.md
cat Linux_arm64_checksum/* >> release_notes.md
echo '# Linux ARM' >> release_notes.md
cat Linux_arm_checksum/* >> release_notes.md
echo '# Windows AMD64' >> release_notes.md
cat Windows_amd64_checksum/* >> release_notes.md
echo '```' >> release_notes.md
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.fetch_release.outputs.id }}/assets{?name,label} draft: true
asset_path: ./dist/${{ steps.make_dist.outputs.windows_amd64_archive }} prerelease: false
asset_name: ${{ steps.make_dist.outputs.windows_amd64_archive }} body_path: release_notes.md
asset_content_type: application/gzip files: |
Linux_amd64_archive/*
Linux_arm64_archive/*
Linux_arm_archive/*
Windows_amd64_archive/*
- name: Delete artefacts
uses: geekyeggo/delete-artifact@v1
with:
failOnError: false
name: |
Linux_amd64_archive
Linux_amd64_checksum
Linux_arm64_archive
Linux_arm64_checksum
Linux_arm_archive
Linux_arm_checksum
Windows_amd64_archive
Windows_amd64_checksum

View File

@ -513,26 +513,26 @@ publish-book: | book auditors-book
rm -rf tmp-book rm -rf tmp-book
dist-amd64: dist-amd64:
MAKE="$(MAKE)" \ + MAKE="$(MAKE)" \
scripts/make_dist.sh amd64 scripts/make_dist.sh amd64
dist-arm64: dist-arm64:
MAKE="$(MAKE)" \ + MAKE="$(MAKE)" \
scripts/make_dist.sh arm64 scripts/make_dist.sh arm64
dist-arm: dist-arm:
MAKE="$(MAKE)" \ + MAKE="$(MAKE)" \
scripts/make_dist.sh arm scripts/make_dist.sh arm
dist-win64: dist-win64:
MAKE="$(MAKE)" \ + MAKE="$(MAKE)" \
scripts/make_dist.sh win64 scripts/make_dist.sh win64
dist: dist:
$(MAKE) dist-amd64 + $(MAKE) dist-amd64
$(MAKE) dist-arm64 + $(MAKE) dist-arm64
$(MAKE) dist-arm + $(MAKE) dist-arm
$(MAKE) dist-win64 + $(MAKE) dist-win64
#- this simple test will show any missing dynamically-linked Glibc symbols in the target distro #- this simple test will show any missing dynamically-linked Glibc symbols in the target distro
dist-test: dist-test:

View File

@ -1,16 +1,8 @@
# The build is reproducible only if this base image stays the same. # The build is reproducible only if this base image stays the same.
FROM statusteam/nimbus_beacon_node:dist_base_20210105213024_arm@sha256:2096aeba814f15d25dcf96b105197d5389d4bc9443fe20fec775868fac21d47a FROM statusteam/nimbus_beacon_node:dist_base_20210310012752_arm_v2@sha256:65919842dc7e17386399ae12b175e9996f5ef038ad6e228000392a1ff6465082
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
ARG QEMU_NAME
ARG QEMU_DIR
# We need the host's registered binfmt_misc "interpreter" inside the container,
# for that transparent virtualisation to work.
# Don't bother deleting it at the end, because this image is not being pushed to the hub.
COPY $QEMU_NAME $QEMU_DIR
ARG USER_ID ARG USER_ID
ARG GROUP_ID ARG GROUP_ID

View File

@ -1,16 +1,8 @@
# The build is reproducible only if this base image stays the same. # The build is reproducible only if this base image stays the same.
FROM statusteam/nimbus_beacon_node:dist_base_20210105215256_arm64@sha256:472b1625f9d0fbdff3edc7543490980e128bef26ca4e7768a5f1b43fbf85e941 FROM statusteam/nimbus_beacon_node:dist_base_20210310021543_arm64_v2@sha256:9f63432ec61cae086235359db84575de7edd0b78320e3590285d273cbab79de2
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
ARG QEMU_NAME
ARG QEMU_DIR
# We need the host's registered binfmt_misc "interpreter" inside the container,
# for that transparent virtualisation to work.
# Don't bother deleting it at the end, because this image is not being pushed to the hub.
COPY $QEMU_NAME $QEMU_DIR
ARG USER_ID ARG USER_ID
ARG GROUP_ID ARG GROUP_ID

View File

@ -6,23 +6,14 @@
# it once, upload it to Docker Hub and make sure it's being pulled regularly so # it once, upload it to Docker Hub and make sure it's being pulled regularly so
# it's not deleted after 6 months of inactivity. # it's not deleted after 6 months of inactivity.
# >=glibc-2.28 breaks things for us: https://bugs.launchpad.net/qemu/+bug/1805913 FROM ubuntu:20.04
FROM arm32v7/ubuntu:18.04
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
ARG QEMU_NAME
ARG QEMU_DIR
# We need the host's registered binfmt_misc "interpreter" inside the container,
# for that transparent virtualisation to work.
COPY $QEMU_NAME $QEMU_DIR
# We delete the static Qemu binary when we're done with it, because it might
# not run on other systems. Let the child image copy it again.
ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC"
RUN apt-get -qq update \ RUN apt-get -qq update \
&& apt-get -qq -y install build-essential git &>/dev/null \ && apt-get -qq -y install build-essential git \
libc6-armhf-armel-cross libc6-dev-armel-armhf-cross binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf &>/dev/null \
&& apt-get -qq clean \ && apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* "${QEMU_DIR}/${QEMU_NAME}" && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

View File

@ -6,22 +6,14 @@
# it once, upload it to Docker Hub and make sure it's being pulled regularly so # it once, upload it to Docker Hub and make sure it's being pulled regularly so
# it's not deleted after 6 months of inactivity. # it's not deleted after 6 months of inactivity.
FROM arm64v8/ubuntu:20.04 FROM ubuntu:20.04
SHELL ["/bin/bash", "-c"] SHELL ["/bin/bash", "-c"]
ARG QEMU_NAME
ARG QEMU_DIR
# We need the host's registered binfmt_misc "interpreter" inside the container,
# for that transparent virtualisation to work.
COPY $QEMU_NAME $QEMU_DIR
# We delete the static Qemu binary when we're done with it, because it might
# not run on other systems. Let the child image copy it again.
ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC"
RUN apt-get -qq update \ RUN apt-get -qq update \
&& apt-get -qq -y install build-essential git &>/dev/null \ && apt-get -qq -y install build-essential git \
binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu &>/dev/null \
&& apt-get -qq clean \ && apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* "${QEMU_DIR}/${QEMU_NAME}" && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

View File

@ -17,10 +17,10 @@ build-amd64:
$(CURDIR)/make_base_image.sh amd64 "$(IMAGE_NAME)" $(CURDIR)/make_base_image.sh amd64 "$(IMAGE_NAME)"
build-arm64: build-arm64:
$(CURDIR)/make_base_image.sh arm64 "$(IMAGE_NAME)_arm64" $(CURDIR)/make_base_image.sh arm64 "$(IMAGE_NAME)_arm64_v2"
build-arm: build-arm:
$(CURDIR)/make_base_image.sh arm "$(IMAGE_NAME)_arm" $(CURDIR)/make_base_image.sh arm "$(IMAGE_NAME)_arm_v2"
build-win64: build-win64:
$(CURDIR)/make_base_image.sh win64 "$(IMAGE_NAME)_win64" $(CURDIR)/make_base_image.sh win64 "$(IMAGE_NAME)_win64"
@ -33,10 +33,10 @@ build-win64:
# docker push $(IMAGE_NAME) # docker push $(IMAGE_NAME)
#push-arm64: build-arm64 #push-arm64: build-arm64
# docker push $(IMAGE_NAME)_arm64 # docker push $(IMAGE_NAME)_arm64_v2
#push-arm: build-arm #push-arm: build-arm
# docker push $(IMAGE_NAME)_arm # docker push $(IMAGE_NAME)_arm_v2
#push-win64: build-win64 #push-win64: build-win64
# docker push $(IMAGE_NAME)_win64 # docker push $(IMAGE_NAME)_win64

View File

@ -7,8 +7,7 @@
# at your option. This file may not be copied, modified, or distributed except # at your option. This file may not be copied, modified, or distributed except
# according to those terms. # according to those terms.
# Build base Docker images for making distributable binaries, using Qemu for # Build base Docker images for making distributable binaries.
# foreign architectures.
# Should be used from "build-*" Make targets, passing the target architecture's # Should be used from "build-*" Make targets, passing the target architecture's
# name and Docker image tag as parameters. # name and Docker image tag as parameters.
@ -23,50 +22,9 @@ fi
ARCH="${1}" ARCH="${1}"
DOCKER_TAG="${2}" DOCKER_TAG="${2}"
if [[ "${ARCH}" == "amd64" || "${ARCH}" == "win64" ]]; then
USE_QEMU=0
else
USE_QEMU=1
if [[ "${ARCH}" == "arm64" ]]; then
BINFMT_NAME="aarch64"
elif [[ "${ARCH}" == "arm" ]]; then
BINFMT_NAME="arm"
fi
fi
DOCKER_EXTRA_ARGS=""
if [[ "${USE_QEMU}" == "1" ]]; then
# We need qemu-user-static installed and registered in binfmt_misc, on the host
# (`apt install qemu binfmt-support qemu-user-static` should do the trick on Debian-based distros).
# The actual binary name varies from one distro to another and we need a copy inside the container.
if [[ ! -f /proc/sys/fs/binfmt_misc/qemu-${BINFMT_NAME} ]]; then
echo "binfmt_misc not set up properly. Aborting."
echo "You may have to run 'apt install qemu binfmt-support qemu-user-static' on a Debian-based distro."
exit 1
fi
QEMU_PATH="$(grep '^interpreter' /proc/sys/fs/binfmt_misc/qemu-${BINFMT_NAME} | cut -d ' ' -f 2)"
QEMU_NAME="$(basename ${QEMU_PATH})"
QEMU_DIR="$(dirname ${QEMU_PATH})"
DOCKER_EXTRA_ARGS="\
--build-arg QEMU_NAME=${QEMU_NAME} \
--build-arg QEMU_DIR=${QEMU_DIR} \
"
fi
if [[ "${USE_QEMU}" == "1" ]]; then
cp -a "${QEMU_PATH}" .
fi
DOCKER_BUILDKIT=1 \ DOCKER_BUILDKIT=1 \
docker build \ docker build \
-t ${DOCKER_TAG} \ -t ${DOCKER_TAG} \
--progress=plain \ --progress=plain \
${DOCKER_EXTRA_ARGS} \
-f Dockerfile.${ARCH} . -f Dockerfile.${ARCH} .
if [[ "${USE_QEMU}" == "1" ]]; then
rm "${QEMU_NAME}"
fi

21
docker/dist/binaries/Dockerfile.arm vendored Normal file
View File

@ -0,0 +1,21 @@
FROM arm32v7/debian:bullseye-slim
SHELL ["/bin/bash", "-c"]
# We need the host's registered binfmt_misc "interpreter" inside the container,
# for that transparent virtualisation to work.
COPY "qemu-arm-static" "/usr/bin/"
# Likely to match the first regular user:group created on the host.
RUN addgroup --gid 1000 user; \
adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user;
USER user
STOPSIGNAL SIGINT
# Docker refuses to copy the source directory here, so read it as "nimbus-eth2/*"
COPY "nimbus-eth2" "/home/user/nimbus-eth2/"
WORKDIR "/home/user/nimbus-eth2/"
ENTRYPOINT ["/home/user/nimbus-eth2/build/nimbus_beacon_node"]

21
docker/dist/binaries/Dockerfile.arm64 vendored Normal file
View File

@ -0,0 +1,21 @@
FROM arm64v8/debian:bullseye-slim
SHELL ["/bin/bash", "-c"]
# We need the host's registered binfmt_misc "interpreter" inside the container,
# for that transparent virtualisation to work.
COPY "qemu-aarch64-static" "/usr/bin/"
# Likely to match the first regular user:group created on the host.
RUN addgroup --gid 1000 user; \
adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user;
USER user
STOPSIGNAL SIGINT
# Docker refuses to copy the source directory here, so read it as "nimbus-eth2/*"
COPY "nimbus-eth2" "/home/user/nimbus-eth2/"
WORKDIR "/home/user/nimbus-eth2/"
ENTRYPOINT ["/home/user/nimbus-eth2/build/nimbus_beacon_node"]

View File

@ -29,20 +29,15 @@ if [[ "${PLATFORM}" == "Windows_amd64" ]]; then
-j$(nproc) \ -j$(nproc) \
USE_LIBBACKTRACE=0 \ USE_LIBBACKTRACE=0 \
QUICK_AND_DIRTY_COMPILER=1 \ QUICK_AND_DIRTY_COMPILER=1 \
deps deps-common build/generate_makefile
make \ # This can be reduced to `make CC=... ...` when it becomes possible to
-C vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc \ # replace `CC=gcc` with `CC=$(CC)` in "vendor/nimbus-build-system/makefiles/targets.mk".
-f Makefile.mingw \
clean &>/dev/null
make \ make \
-j$(nproc) \ -j$(nproc) \
-C vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc \ -C vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc \
-f Makefile.mingw \ -f Makefile.mingw \
CC=x86_64-w64-mingw32.static-gcc \ CC=x86_64-w64-mingw32.static-gcc \
libminiupnpc.a &>/dev/null libminiupnpc.a &>/dev/null
make \
-C vendor/nim-nat-traversal/vendor/libnatpmp-upstream \
clean &>/dev/null
make \ make \
-j$(nproc) \ -j$(nproc) \
-C vendor/nim-nat-traversal/vendor/libnatpmp-upstream \ -C vendor/nim-nat-traversal/vendor/libnatpmp-upstream \
@ -55,6 +50,36 @@ if [[ "${PLATFORM}" == "Windows_amd64" ]]; then
LOG_LEVEL="TRACE" \ LOG_LEVEL="TRACE" \
NIMFLAGS="-d:disableMarchNative -d:chronicles_sinks=textlines -d:chronicles_colors=none --os:windows --gcc.exe=x86_64-w64-mingw32.static-gcc --gcc.linkerexe=x86_64-w64-mingw32.static-gcc --passL:-static" \ NIMFLAGS="-d:disableMarchNative -d:chronicles_sinks=textlines -d:chronicles_colors=none --os:windows --gcc.exe=x86_64-w64-mingw32.static-gcc --gcc.linkerexe=x86_64-w64-mingw32.static-gcc --passL:-static" \
${BINARIES} ${BINARIES}
elif [[ "${PLATFORM}" == "Linux_arm32v7" ]]; then
CC="arm-linux-gnueabihf-gcc"
make \
-j$(nproc) \
USE_LIBBACKTRACE=0 \
QUICK_AND_DIRTY_COMPILER=1 \
deps-common build/generate_makefile
make \
-j$(nproc) \
USE_LIBBACKTRACE=0 \
LOG_LEVEL="TRACE" \
CC="${CC}" \
NIMFLAGS="-d:disableMarchNative -d:chronicles_sinks=textlines -d:chronicles_colors=none --cpu:arm --gcc.exe=${CC} --gcc.linkerexe=${CC}" \
PARTIAL_STATIC_LINKING=1 \
${BINARIES}
elif [[ "${PLATFORM}" == "Linux_arm64v8" ]]; then
CC="aarch64-linux-gnu-gcc"
make \
-j$(nproc) \
USE_LIBBACKTRACE=0 \
QUICK_AND_DIRTY_COMPILER=1 \
deps-common build/generate_makefile
make \
-j$(nproc) \
USE_LIBBACKTRACE=0 \
LOG_LEVEL="TRACE" \
CC="${CC}" \
NIMFLAGS="-d:disableMarchNative -d:chronicles_sinks=textlines -d:chronicles_colors=none --cpu:arm64 --gcc.exe=${CC} --gcc.linkerexe=${CC}" \
PARTIAL_STATIC_LINKING=1 \
${BINARIES}
else else
make \ make \
-j$(nproc) \ -j$(nproc) \

View File

@ -7,7 +7,7 @@
# at your option. This file may not be copied, modified, or distributed except # at your option. This file may not be copied, modified, or distributed except
# according to those terms. # according to those terms.
# Build release binaries fit for public distribution, using Docker and Qemu. # Build release binaries fit for public distribution, using Docker.
# Should be used from "dist-*" Make targets, passing the target architecture's name as a parameter. # Should be used from "dist-*" Make targets, passing the target architecture's name as a parameter.
set -e set -e
@ -16,62 +16,22 @@ cd "$(dirname "${BASH_SOURCE[0]}")"/..
REPO_DIR="${PWD}" REPO_DIR="${PWD}"
ARCH="${1:-amd64}" ARCH="${1:-amd64}"
if [[ "${ARCH}" == "amd64" || "${ARCH}" == "win64" ]]; then
USE_QEMU=0
else
USE_QEMU=1
if [[ "${ARCH}" == "arm64" ]]; then
BINFMT_NAME="aarch64"
elif [[ "${ARCH}" == "arm" ]]; then
BINFMT_NAME="arm"
fi
fi
DOCKER_TAG="nimbus-eth2-dist-${ARCH}" DOCKER_TAG="nimbus-eth2-dist-${ARCH}"
DOCKER_EXTRA_ARGS=""
if [[ "${USE_QEMU}" == "1" ]]; then
# We need qemu-user-static installed and registered in binfmt_misc, on the host
# (`apt install qemu binfmt-support qemu-user-static` should do the trick on Debian-based distros).
# The actual binary name varies from one distro to another and we need a copy inside the container.
if [[ ! -f /proc/sys/fs/binfmt_misc/qemu-${BINFMT_NAME} ]]; then
echo "binfmt_misc not set up properly. Aborting."
echo "You may have to run 'apt install qemu binfmt-support qemu-user-static' on a Debian-based distro."
exit 1
fi
QEMU_PATH="$(grep '^interpreter' /proc/sys/fs/binfmt_misc/qemu-${BINFMT_NAME} | cut -d ' ' -f 2)"
QEMU_NAME="$(basename ${QEMU_PATH})"
QEMU_DIR="$(dirname ${QEMU_PATH})"
DOCKER_EXTRA_ARGS="\
--build-arg QEMU_NAME=${QEMU_NAME} \
--build-arg QEMU_DIR=${QEMU_DIR} \
"
fi
docker rm ${DOCKER_TAG} &>/dev/null || true docker rm ${DOCKER_TAG} &>/dev/null || true
cd docker/dist cd docker/dist
if [[ "${USE_QEMU}" == "1" ]]; then
cp -a "${QEMU_PATH}" .
fi
DOCKER_BUILDKIT=1 \ DOCKER_BUILDKIT=1 \
docker build \ docker build \
-t ${DOCKER_TAG} \ -t ${DOCKER_TAG} \
--progress=plain \ --progress=plain \
--build-arg USER_ID=$(id -u) \ --build-arg USER_ID=$(id -u) \
--build-arg GROUP_ID=$(id -g) \ --build-arg GROUP_ID=$(id -g) \
${DOCKER_EXTRA_ARGS} \
-f Dockerfile.${ARCH} . -f Dockerfile.${ARCH} .
docker run --rm --name ${DOCKER_TAG} -v ${REPO_DIR}:/home/user/nimbus-eth2 ${DOCKER_TAG} docker run --rm --name ${DOCKER_TAG} -v ${REPO_DIR}:/home/user/nimbus-eth2 ${DOCKER_TAG}
if [[ "${USE_QEMU}" == "1" ]]; then
rm "${QEMU_NAME}"
fi
cd - &>/dev/null cd - &>/dev/null
ls -l dist ls -l dist