@@ -36,10 +36,82 @@ jobs:
36
36
- uses : actions/checkout@v4
37
37
- name : Set up Docker Buildx
38
38
uses : docker/setup-buildx-action@v3
39
- - name : Build and push Docker image
39
+ - name : Set up Docker Buildx cache
40
+ uses : actions/cache@v3
41
+ with :
42
+ path : /tmp/.buildx-cache
43
+ key : ${{ runner.os }}-buildx-${{ github.sha }}
44
+ restore-keys : |
45
+ ${{ runner.os }}-buildx-
46
+ - name : Build Docker image for amd64
47
+ uses : docker/build-push-action@v5
48
+ with :
49
+ platforms : linux/amd64
50
+ push : false
51
+ tags : |
52
+ cybuerg/cfspeedtest:${{ github.sha }}-amd64
53
+ cache-from : type=local,src=/tmp/.buildx-cache
54
+ cache-to : type=local,dest=/tmp/.buildx-cache-amd64,mode=max
55
+ outputs : type=docker,dest=/tmp/docker-image-amd64.tar
56
+
57
+ - name : Build Docker image for arm64
40
58
uses : docker/build-push-action@v5
41
59
with :
42
- platforms : linux/amd64,linux/ arm64
60
+ platforms : linux/arm64
43
61
push : false
44
62
tags : |
45
- cybuerg/cfspeedtest:${{ github.sha }}
63
+ cybuerg/cfspeedtest:${{ github.sha }}-arm64
64
+ cache-from : type=local,src=/tmp/.buildx-cache
65
+ cache-to : type=local,dest=/tmp/.buildx-cache-arm64,mode=max
66
+ outputs : type=docker,dest=/tmp/docker-image-arm64.tar
67
+ - name : Merge and move cache
68
+ run : |
69
+ mkdir -p /tmp/.buildx-cache-new
70
+ cp -r /tmp/.buildx-cache-amd64/* /tmp/.buildx-cache-new/ || true
71
+ cp -r /tmp/.buildx-cache-arm64/* /tmp/.buildx-cache-new/ || true
72
+ rm -rf /tmp/.buildx-cache
73
+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
74
+ - name : Upload Docker images as artifacts
75
+ uses : actions/upload-artifact@v4
76
+ with :
77
+ name : docker-images
78
+ path : |
79
+ /tmp/docker-image-amd64.tar
80
+ /tmp/docker-image-arm64.tar
81
+ retention-days : 1
82
+
83
+ verify-docker-image :
84
+ needs : docker-build
85
+ runs-on : ubuntu-latest
86
+ strategy :
87
+ matrix :
88
+ platform : [linux/amd64, linux/arm64]
89
+ steps :
90
+ - name : Download Docker images
91
+ uses : actions/download-artifact@v4
92
+ with :
93
+ name : docker-images
94
+ path : /tmp
95
+ - name : Load Docker image
96
+ run : |
97
+ if [ "${{ matrix.platform }}" = "linux/amd64" ]; then
98
+ docker load < /tmp/docker-image-amd64.tar
99
+ else
100
+ docker load < /tmp/docker-image-arm64.tar
101
+ fi
102
+ - name : Verify amd64 image
103
+ if : matrix.platform == 'linux/amd64'
104
+ run : |
105
+ docker run cybuerg/cfspeedtest:${{ github.sha }}-amd64 --help
106
+ docker run --entrypoint /bin/sh cybuerg/cfspeedtest:${{ github.sha }}-amd64 -c "file /usr/local/bin/cfspeedtest" | grep "x86-64"
107
+ - name : Set up QEMU
108
+ if : matrix.platform == 'linux/arm64'
109
+ uses : docker/setup-qemu-action@v3
110
+ with :
111
+ platforms : arm64
112
+
113
+ - name : Verify arm64 image
114
+ if : matrix.platform == 'linux/arm64'
115
+ run : |
116
+ docker run --platform linux/arm64 cybuerg/cfspeedtest:${{ github.sha }}-arm64 --help
117
+ docker run --platform linux/arm64 --entrypoint /bin/sh cybuerg/cfspeedtest:${{ github.sha }}-arm64 -c "file /usr/local/bin/cfspeedtest" | grep "aarch64"
0 commit comments