1
+ # This workflow builds and publishes official Docker images to Docker Hub.
2
+ # It handles multi-platform builds (amd64, arm/v7, arm64/v8) and pushes tagged releases.
3
+ # This workflow is triggered on tags, specific branches, and can be manually dispatched.
4
+ # For quick build checks during development, see docker-check.yml
1
5
name : Docker Push
2
6
3
7
on :
@@ -38,21 +42,19 @@ jobs:
38
42
LEGACY_IMAGE_NAME : ipfs/go-ipfs
39
43
steps :
40
44
- name : Check out the repo
41
- uses : actions/checkout@v4
45
+ uses : actions/checkout@v5
42
46
43
47
- name : Set up QEMU
44
48
uses : docker/setup-qemu-action@v3
45
49
46
50
- name : Set up Docker Buildx
47
51
uses : docker/setup-buildx-action@v3
48
52
49
- - name : Cache Docker layers
50
- uses : actions/cache@v4
53
+ - name : Log in to Docker Hub
54
+ uses : docker/login-action@v3
51
55
with :
52
- path : /tmp/.buildx-cache
53
- key : ${{ runner.os }}-buildx-${{ github.sha }}
54
- restore-keys : |
55
- ${{ runner.os }}-buildx-
56
+ username : ${{ vars.DOCKER_USERNAME }}
57
+ password : ${{ secrets.DOCKER_PASSWORD }}
56
58
57
59
- name : Get tags
58
60
id : tags
63
65
echo "EOF" >> $GITHUB_OUTPUT
64
66
shell : bash
65
67
66
- - name : Log in to Docker Hub
67
- uses : docker/login-action@v3
68
- with :
69
- username : ${{ vars.DOCKER_USERNAME }}
70
- password : ${{ secrets.DOCKER_PASSWORD }}
71
-
72
68
# We have to build each platform separately because when using multi-arch
73
69
# builds, only one platform is being loaded into the cache. This would
74
70
# prevent us from testing the other platforms.
81
77
load : true
82
78
file : ./Dockerfile
83
79
tags : ${{ env.IMAGE_NAME }}:linux-amd64
84
- cache-from : type=local,src=/tmp/.buildx-cache
85
- cache-to : type=local,dest=/tmp/.buildx-cache-new
80
+ cache-from : |
81
+ type=gha
82
+ type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
83
+ cache-to : type=gha,mode=max
86
84
87
85
- name : Build Docker image (linux/arm/v7)
88
86
uses : docker/build-push-action@v6
93
91
load : true
94
92
file : ./Dockerfile
95
93
tags : ${{ env.IMAGE_NAME }}:linux-arm-v7
96
- cache-from : type=local,src=/tmp/.buildx-cache
97
- cache-to : type=local,dest=/tmp/.buildx-cache-new
94
+ cache-from : |
95
+ type=gha
96
+ type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
97
+ cache-to : type=gha,mode=max
98
98
99
99
- name : Build Docker image (linux/arm64/v8)
100
100
uses : docker/build-push-action@v6
@@ -105,8 +105,10 @@ jobs:
105
105
load : true
106
106
file : ./Dockerfile
107
107
tags : ${{ env.IMAGE_NAME }}:linux-arm64-v8
108
- cache-from : type=local,src=/tmp/.buildx-cache
109
- cache-to : type=local,dest=/tmp/.buildx-cache-new
108
+ cache-from : |
109
+ type=gha
110
+ type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
111
+ cache-to : type=gha,mode=max
110
112
111
113
# We test all the images on amd64 host here. This uses QEMU to emulate
112
114
# the other platforms.
@@ -132,12 +134,9 @@ jobs:
132
134
push : true
133
135
file : ./Dockerfile
134
136
tags : " ${{ github.event.inputs.tags || steps.tags.outputs.value }}"
135
- cache-from : type=local,src=/tmp/.buildx-cache-new
136
- cache-to : type=local,dest=/tmp/.buildx-cache-new
137
-
138
- # https://github.com/docker/build-push-action/issues/252
139
- # https://github.com/moby/buildkit/issues/1896
140
- - name : Move cache to limit growth
141
- run : |
142
- rm -rf /tmp/.buildx-cache
143
- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
137
+ cache-from : |
138
+ type=gha
139
+ type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
140
+ cache-to : |
141
+ type=gha,mode=max
142
+ type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
0 commit comments