Skip to content

Commit 252649e

Browse files
authoredFeb 5, 2025··
Release action - Separate runner for amd64 and arm64 (main) (#5130)
* Release action - Separate runner for amd64 and arm64 (main) Previously arm64 images were created on a standard amd64 runner using qemu. qemu emulation is very slow and there have been recent issues. Native image creation is faster and more reliable. This change creates separate runners for amd64 and arm64. A new job is then needed to combine the image digests into a multi-architecture manifest that gets pushed to Docker Hub and ghcr. Signed-off-by: David Enyeart <[email protected]> * Update ubuntu-20.04 to ubuntu-22.04 in docs Update docs to reflect the update from ubuntu-20.04 to ubuntu-22.04. Signed-off-by: David Enyeart <[email protected]> --------- Signed-off-by: David Enyeart <[email protected]>
1 parent 1325059 commit 252649e

File tree

3 files changed

+114
-37
lines changed

3 files changed

+114
-37
lines changed
 

‎.github/workflows/release.yml

+112-35
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
strategy:
2626
matrix:
2727
include:
28-
- image: fabric-ubuntu-22.04
28+
- image: ubuntu-22.04
2929
target: linux
3030
arch: amd64
31-
- image: fabric-ubuntu-22.04
31+
- image: ubuntu-22.04
3232
target: linux
3333
arch: arm64
3434
- image: macos-11
@@ -40,7 +40,7 @@ jobs:
4040
- image: fabric-windows-latest
4141
target: windows
4242
arch: amd64
43-
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
43+
runs-on: ubuntu-22.04
4444
steps:
4545
- name: Checkout Fabric Code
4646
uses: actions/checkout@v4
@@ -62,9 +62,10 @@ jobs:
6262
# <path> of the artifact may include multiple files.
6363
path: release/${{ matrix.target }}-${{ matrix.arch }}/*.tar.gz
6464

65-
build-and-push-docker-images:
66-
name: Build and Push
67-
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
65+
# build native images using a different runner for each architecture (faster and more reliable than using qemu to build multi-architecture images on ubuntu-22.04)
66+
build-and-push-native-docker-images:
67+
name: Build and Push native images
68+
runs-on: ${{ matrix.runner }}
6869

6970
permissions:
7071
contents: read
@@ -73,9 +74,15 @@ jobs:
7374
strategy:
7475
fail-fast: false
7576
matrix:
76-
registry:
77-
- docker.io
78-
- ghcr.io
77+
78+
runner:
79+
- ubuntu-22.04 # creates linux-amd64 images
80+
- ubuntu-22.04-arm # creates linux-arm64 images
81+
82+
# Dynamic matrix
83+
# If owner is 'hyperledger' run job for Docker Hub and ghcr, otherwise for personal forks just run job for ghcr
84+
registry: ${{ fromJSON(github.repository_owner == 'hyperledger' && '["docker.io", "ghcr.io"]' || '["ghcr.io"]') }}
85+
7986
component:
8087
- name: baseos
8188
context: images/baseos
@@ -87,71 +94,141 @@ jobs:
8794
context: .
8895

8996
steps:
90-
- name: Skip Docker Hub publish for forks
91-
if: ${{ github.repository_owner != 'hyperledger' && matrix.registry == 'docker.io' }}
92-
run: exit 1
93-
94-
- name: Set up QEMU
95-
uses: docker/setup-qemu-action@v3
96-
97-
- name: Set up Docker Buildx
98-
uses: docker/setup-buildx-action@v3
99-
with:
100-
buildkitd-flags: --debug
101-
buildkitd-config-inline: |
102-
[worker.oci]
103-
max-parallelism = 1
10497

10598
- name: Checkout
10699
uses: actions/checkout@v4
107-
100+
108101
- name: Login to the ${{ matrix.registry }} Container Registry
109102
uses: docker/login-action@v3
110103
with:
111104
registry: ${{ matrix.registry }}
112105
username: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
113106
password: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
114107

108+
- name: Set up Docker Buildx
109+
uses: docker/setup-buildx-action@v3
110+
115111
- name: Docker meta
116112
id: meta
117113
uses: docker/metadata-action@v5
118114
with:
119115
images: ${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}
120-
tags: |
121-
type=semver,pattern={{version}}
122-
type=semver,pattern={{major}}.{{minor}}
123-
type=semver,pattern={{major}}.{{minor}}.{{patch}}
124116

125117
- name: Build and push ${{ matrix.component.name }} Image
126-
id: push
127-
uses: docker/build-push-action@v5
118+
id: build-and-push
119+
uses: docker/build-push-action@v6
128120
with:
129121
context: ${{ matrix.component.context }}
130122
file: images/${{ matrix.component.name }}/Dockerfile
131-
platforms: linux/amd64,linux/arm64
132-
tags: ${{ steps.meta.outputs.tags }}
133-
push: ${{ github.event_name != 'pull_request' }}
134123
labels: ${{ steps.meta.outputs.labels }}
135124
build-args: |
136125
FABRIC_VER=${{ env.FABRIC_VER }}
137126
UBUNTU_VER=${{ env.UBUNTU_VER }}
138127
GO_VER=${{ env.GO_VER }}
139128
GO_TAGS=
129+
outputs: type=image,"name=${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}",push-by-digest=true,name-canonical=true,push=true
130+
131+
- name: Export digest
132+
run: |
133+
mkdir -p ${{ runner.temp }}/digests/${{ matrix.registry }}/${{ matrix.component.name }}
134+
digest="${{ steps.build-and-push.outputs.digest }}"
135+
touch "${{ runner.temp }}/digests/${{ matrix.registry }}/${{ matrix.component.name }}/${digest#sha256:}"
136+
137+
- name: Upload digest
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: digests-${{ matrix.registry }}-${{ matrix.component.name }}-${{ matrix.runner }}
141+
path: ${{ runner.temp }}/digests/${{ matrix.registry }}/${{ matrix.component.name }}/*
142+
if-no-files-found: error
143+
retention-days: 1
144+
145+
# This job merges the architecture-specific digests for the images created above
146+
# and creates a multi-architecture image manifest with user-friendly tags
147+
merge-and-push-multi-arch-image:
148+
name: Merge and Push multi-arch image
149+
runs-on: ubuntu-22.04
150+
needs:
151+
- build-and-push-native-docker-images
152+
153+
permissions:
154+
contents: read
155+
packages: write
156+
157+
strategy:
158+
fail-fast: false
159+
matrix:
160+
161+
# Dynamic matrix
162+
# If owner is 'hyperledger' run job for Docker Hub and ghcr, otherwise for personal forks just run job for ghcr
163+
registry: ${{ fromJSON(github.repository_owner == 'hyperledger' && '["docker.io", "ghcr.io"]' || '["ghcr.io"]') }}
164+
165+
component:
166+
- name: baseos
167+
context: images/baseos
168+
- name: ccenv
169+
context: images/ccenv
170+
- name: peer
171+
context: .
172+
- name: orderer
173+
context: .
174+
175+
steps:
176+
177+
- name: Download digests
178+
uses: actions/download-artifact@v4
179+
with:
180+
path: ${{ runner.temp }}/digests/${{ matrix.registry }}/${{ matrix.component.name }}
181+
pattern: digests-${{ matrix.registry }}-${{ matrix.component.name }}-*
182+
merge-multiple: true
183+
184+
- name: Login to the ${{ matrix.registry }} Container Registry
185+
uses: docker/login-action@v3
186+
with:
187+
registry: ${{ matrix.registry }}
188+
username: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
189+
password: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
190+
191+
- name: Set up Docker Buildx
192+
uses: docker/setup-buildx-action@v3
193+
194+
- name: Docker meta
195+
id: meta
196+
uses: docker/metadata-action@v5
197+
with:
198+
images: ${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}
199+
tags: |
200+
type=semver,pattern={{version}}
201+
type=semver,pattern={{major}}.{{minor}}
202+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
203+
204+
- name: Create manifest list and push # combines the downloaded amd64 and arm64 digests and pushes multi-architecture manifest with the tags specified above
205+
working-directory: ${{ runner.temp }}/digests/${{ matrix.registry }}/${{ matrix.component.name }}
206+
run: |
207+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
208+
$(printf '${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}@sha256:%s ' *)
209+
210+
- name: Inspect image
211+
run: |
212+
docker buildx imagetools inspect ${{ matrix.registry }}/${{ github.repository_owner }}/fabric-${{ matrix.component.name }}:${{ steps.meta.outputs.version }}
140213
141214
create-release:
142215
name: Create GitHub Release
143216
needs:
144217
- build-binaries
145-
- build-and-push-docker-images
146-
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
218+
- merge-and-push-multi-arch-image
219+
runs-on: ubuntu-22.04
147220
permissions:
148221
contents: write
149222
steps:
150223
- name: Checkout Fabric Code
151224
uses: actions/checkout@v4
225+
152226
- name: Download Artifacts
153227
id: download
154228
uses: actions/download-artifact@v4
229+
with:
230+
pattern: "release-*"
231+
155232
- name: Release Fabric Version
156233
uses: ncipollo/release-action@v1
157234
with:

‎docs/source/prereqs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ path is to use WSL2 (Windows Subsystem for Linux version 2) to provide a native
128128

129129
WSL2 may not be installed by default; you can check and install WSL2 by going into "Programs and Features", clicking on "Turn Windows features on or off" and ensuring that both "Windows Subsystem For Linux" and "Virtual Machine Platform" are selected.
130130

131-
Next you will need to install a Linux distribution such as Ubuntu-20.04 and make sure it's set to using version 2 of WSL. Refer to [Install WSL](https://docs.microsoft.com/en-us/windows/wsl/install) for more information.
131+
Next you will need to install a Linux distribution such as Ubuntu-22.04 and make sure it's set to using version 2 of WSL. Refer to [Install WSL](https://docs.microsoft.com/en-us/windows/wsl/install) for more information.
132132

133133
Finally, you need to ensure Docker Desktop has integration enabled for your distribution so it can interact with Docker elements, such as a bash command window. To do this, open the Docker Desktop gui and go into settings, select `Resources` and them `WSL Integration` and ensure the checkbox for enable integration is checked. You should then see your WSL2 linux distribution listed (if you don't then it is probably because it is still a WSL1 distribution and needs to be converted to WSL2) and you can then toggle the switch to enable integration for that distro. Refer to [Docker Desktop WSL2 backend](https://docs.docker.com/desktop/windows/wsl/) for more information
134134

‎vagrant/Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Vagrant.require_version ">= 1.7.4"
99
Vagrant.configure('2') do |config|
10-
config.vm.box = "bento/ubuntu-20.04"
10+
config.vm.box = "bento/ubuntu-22.04"
1111
config.vm.synced_folder "..", "/home/vagrant/fabric"
1212
config.ssh.forward_agent = true
1313

0 commit comments

Comments
 (0)
Please sign in to comment.