@@ -5,92 +5,137 @@ on: [push, pull_request]
5
5
jobs :
6
6
build-bin :
7
7
name : bin
8
- runs-on : ubuntu-22.04-xl
8
+ runs-on : ubuntu-latest
9
9
steps :
10
10
- name : Clone repository
11
11
uses : actions/checkout@v4
12
+
13
+ - name : Cache docker registry
14
+ uses : actions/cache@v3
15
+ with :
16
+ key : registry-${{ github.sha }}
17
+ path : ${{ runner.temp }}/registry
18
+
19
+ - name : Cache Docker layers
20
+ uses : actions/cache@v2
21
+ with :
22
+ path : /tmp/.buildx-cache
23
+ # Key is named differently to avoid collision
24
+ key : ${{ runner.os }}-multi-buildx-${{ github.sha }}
25
+ restore-keys : |
26
+ ${{ runner.os }}-multi-buildx
12
27
13
- - name : Build and export image
28
+ - name : Start local Docker registry
14
29
run : |
15
- docker build -f bin.dockerfile -t bin .
16
- docker save bin -o /tmp/bin-image.tar
30
+ # Docker save / load does not support multi-arch images.
31
+ # This sets up a local registry that I can push the images to.
32
+ docker run -d -p 5000:5000 -e 'REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry' -v '${{ runner.temp }}/registry:/var/lib/registry' registry:2
33
+
34
+ - name : Set up QEMU
35
+ uses : docker/setup-qemu-action@v3
17
36
18
- - name : Upload artifact
19
- uses : actions/upload-artifact@v4
37
+ - name : Set up Docker Buildx
38
+ uses : docker/setup-buildx-action@v3
20
39
with :
21
- name : bin-image
22
- path : /tmp/bin-image.tar
40
+ driver-opts : network=host
41
+
42
+ - name : Build image
43
+ run : |
44
+ docker buildx build -f bin.dockerfile --platform=linux/amd64,linux/arm64 -t localhost:5000/bin --push .
23
45
24
46
build :
25
47
needs : build-bin
26
48
name : ${{ matrix.kind }}
27
- runs-on : ubuntu-22.04-xl
49
+ runs-on : ubuntu-latest
28
50
strategy :
29
51
matrix :
30
52
kind : ["alpine", "centos", "debian", "distroless", "ubuntu"]
31
53
steps :
32
54
- name : Clone repository
33
55
uses : actions/checkout@v4
56
+
57
+ - name : Cache docker registry
58
+ uses : actions/cache@v3
59
+ with :
60
+ key : registry-${{ github.sha }}
61
+ fail-on-cache-miss : true
62
+ path : ${{ runner.temp }}/registry
34
63
35
- - name : Download bin image artifact
36
- uses : actions/download-artifact@v4
64
+ - name : Cache Docker layers
65
+ uses : actions/cache@v2
37
66
with :
38
- name : bin-image
39
- path : /tmp
67
+ path : /tmp/.buildx-cache
68
+ # Key is named differently to avoid collision
69
+ key : ${{ runner.os }}-multi-buildx-${{ github.sha }}
70
+ restore-keys : |
71
+ ${{ runner.os }}-multi-buildx
40
72
41
- - name : Load bin image
73
+ - name : Start local Docker registry
42
74
run : |
43
- docker load --input /tmp/bin-image.tar
44
- docker inspect bin
75
+ # Docker save / load does not support multi-arch images.
76
+ # This sets up a local registry that I can push the images to.
77
+ docker run -d -p 5000:5000 -e 'REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry' -v '${{ runner.temp }}/registry:/var/lib/registry' registry:2
78
+
79
+ - name : Set up QEMU
80
+ uses : docker/setup-qemu-action@v3
81
+
82
+ - name : Set up Docker Buildx
83
+ uses : docker/setup-buildx-action@v3
84
+ with :
85
+ driver-opts : network=host
45
86
46
87
- name : Build image
47
88
run : |
48
- docker build -f ${{ matrix.kind }}.dockerfile --build-arg BIN_IMAGE=bin -t ${{ matrix.kind }} .
89
+ docker buildx build -f ${{ matrix.kind }}.dockerfile --platform=linux/amd64,linux/arm64 -- build-arg BIN_IMAGE=localhost:5000/ bin -t localhost:5000/ ${{ matrix.kind }} --push .
49
90
50
91
- name : Test default CMD
51
92
run : |
52
- docker run -t ${{ matrix.kind }}
93
+ docker run -t localhost:5000/ ${{ matrix.kind }}
53
94
54
95
- name : Test if entry script forwards to deno binary
55
96
run : |
56
- docker run -t ${{ matrix.kind }} eval "console.log('Welcome to Deno!')"
97
+ docker run -t localhost:5000/ ${{ matrix.kind }} eval "console.log('Welcome to Deno!')"
57
98
58
99
# if typescript is present in the output, then probably deno --version worked
59
- docker run -t ${{ matrix.kind }} --version | grep typescript
100
+ docker run -t localhost:5000/ ${{ matrix.kind }} --version | grep typescript
60
101
61
102
- name : Test if entry script forwards to other binaries
62
103
if : ${{ matrix.kind != 'distroless' }}
63
104
run : |
64
- docker run -t ${{ matrix.kind }} deno eval "console.log('Welcome to Deno!')"
65
- docker run -t ${{ matrix.kind }} echo 'test entry script'
105
+ docker run -t localhost:5000/${{ matrix.kind }} deno eval "console.log('Welcome to Deno!')"
106
+ docker run -t localhost:5000/${{ matrix.kind }} echo 'test entry script'
107
+
108
+ - name : Print image information
109
+ if : ${{ matrix.kind == 'debian' }}
110
+ run : |
111
+ docker buildx imagetools inspect localhost:5000/${{ matrix.kind }}
112
+
113
+ echo "x86..."
114
+
115
+ docker run --rm --platform linux/amd64 localhost:5000/${{ matrix.kind }} sh -c 'apt-get update -y && apt-get install -y file && file /usr/bin/deno'
116
+
117
+
118
+ echo "ARM..."
119
+ docker run --rm --platform linux/arm64 localhost:5000/${{ matrix.kind }} sh -c 'apt-get update -y && apt-get install -y file && file /usr/bin/deno'
66
120
67
121
- name : Login to Docker Hub
68
- if : github.repository == 'denoland/deno_docker' && startsWith( github.ref, 'refs/tags/')
122
+ if : github.repository == 'denoland/deno_docker' && github.ref_type == 'tag'
69
123
uses : docker/login-action@v3
70
124
with :
71
125
username : ${{ secrets.DOCKERHUB_USERNAME }}
72
126
password : ${{ secrets.DOCKERHUB_PASSWORD }}
73
127
74
128
- name : Push named images
75
- if : github.repository == 'denoland/deno_docker' && startsWith( github.ref, 'refs/tags/')
129
+ if : github.repository == 'denoland/deno_docker' && github.ref_type == 'tag'
76
130
run : |
77
- docker tag ${{ matrix.kind }} denoland/deno:${{ matrix.kind }}-${GITHUB_REF#refs/*/}
78
- docker tag ${{ matrix.kind }} denoland/deno:${{ matrix.kind }}
79
- docker push denoland/deno:${{ matrix.kind }}-${GITHUB_REF#refs/*/}
80
- docker push denoland/deno:${{ matrix.kind }}
131
+ docker buildx imagetools create localhost:5000/${{ matrix.kind }} -t denoland/deno:${{ matrix.kind }}-${{ github.ref_name }} -t denoland/deno:${{ matrix.kind }}
81
132
82
133
- name : Push bin image
83
- if : github.repository == 'denoland/deno_docker' && startsWith( github.ref, 'refs/tags/') && matrix.kind == 'debian'
134
+ if : github.repository == 'denoland/deno_docker' && github.ref_type == 'tag' && matrix.kind == 'debian'
84
135
run : |
85
- docker tag bin denoland/deno:bin-${GITHUB_REF#refs/*/}
86
- docker tag bin denoland/deno:bin
87
- docker push denoland/deno:bin-${GITHUB_REF#refs/*/}
88
- docker push denoland/deno:bin
136
+ docker buildx imagetools create localhost:5000/bin -t denoland/deno:bin-${{ github.ref_name }} -t denoland/deno:bin
89
137
90
138
- name : Push default image
91
- if : github.repository == 'denoland/deno_docker' && startsWith( github.ref, 'refs/tags/') && matrix.kind == 'debian'
139
+ if : github.repository == 'denoland/deno_docker' && github.ref_type == 'tag' && matrix.kind == 'debian'
92
140
run : |
93
- docker tag ${{ matrix.kind }} denoland/deno:${GITHUB_REF#refs/*/}
94
- docker tag ${{ matrix.kind }} denoland/deno:latest
95
- docker push denoland/deno:${GITHUB_REF#refs/*/}
96
- docker push denoland/deno:latest
141
+ docker buildx imagetools create localhost:5000/${{ matrix.kind }} -t denoland/deno:${{ matrix.kind }}-${{ github.ref_name }} -t denoland/deno:latest
0 commit comments