17
17
DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
18
18
IMAGE_NAME : ${{ github.repository_owner}}/lighthouse
19
19
LCLI_IMAGE_NAME : ${{ github.repository_owner }}/lcli
20
+ # Enable self-hosted runners for the sigp repo only.
21
+ SELF_HOSTED_RUNNERS : ${{ github.repository == 'sigp/lighthouse' }}
20
22
21
23
jobs :
22
24
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
48
50
VERSION_SUFFIX : ${{ env.VERSION_SUFFIX }}
49
51
build-docker-single-arch :
50
52
name : build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }}
51
- runs-on : ubuntu-22.04
53
+ # Use self-hosted runners only on the sigp repo.
54
+ runs-on : ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "release"]') || 'ubuntu-22.04' }}
52
55
strategy :
53
56
matrix :
54
57
# FIXME(sproul) re-enable ARM builds
@@ -63,14 +66,13 @@ jobs:
63
66
64
67
needs : [extract-version]
65
68
env :
66
- # We need to enable experimental docker features in order to use `docker buildx`
67
- DOCKER_CLI_EXPERIMENTAL : enabled
68
69
VERSION : ${{ needs.extract-version.outputs.VERSION }}
69
70
VERSION_SUFFIX : ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
70
71
FEATURE_SUFFIX : ${{ matrix.features.version_suffix }}
71
72
steps :
72
73
- uses : actions/checkout@v3
73
74
- name : Update Rust
75
+ if : env.SELF_HOSTED_RUNNERS == 'false'
74
76
run : rustup update stable
75
77
- name : Dockerhub login
76
78
run : |
@@ -79,16 +81,14 @@ jobs:
79
81
run : |
80
82
cargo install cross
81
83
env CROSS_PROFILE=${{ matrix.profile }} CROSS_FEATURES=${{ matrix.features.env }} make build-${{ matrix.binary }}
84
+ - name : Make bin dir
85
+ run : mkdir ./bin
82
86
- name : Move cross-built binary into Docker scope (if ARM)
83
87
if : startsWith(matrix.binary, 'aarch64')
84
- run : |
85
- mkdir ./bin;
86
- mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin;
88
+ run : mv ./target/aarch64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
87
89
- name : Move cross-built binary into Docker scope (if x86_64)
88
90
if : startsWith(matrix.binary, 'x86_64')
89
- run : |
90
- mkdir ./bin;
91
- mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin;
91
+ run : mv ./target/x86_64-unknown-linux-gnu/${{ matrix.profile }}/lighthouse ./bin
92
92
- name : Map aarch64 to arm64 short arch
93
93
if : startsWith(matrix.binary, 'aarch64')
94
94
run : echo "SHORT_ARCH=arm64" >> $GITHUB_ENV
@@ -98,17 +98,24 @@ jobs:
98
98
- name : Set modernity suffix
99
99
if : endsWith(matrix.binary, '-portable') != true
100
100
run : echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV;
101
- # Install dependencies for emulation. Have to create a new builder to pick up emulation support.
102
- - name : Build Dockerfile and push
103
- run : |
104
- docker run --privileged --rm tonistiigi/binfmt --install ${SHORT_ARCH}
105
- docker buildx create --use --name cross-builder
106
- docker buildx build \
107
- --platform=linux/${SHORT_ARCH} \
108
- --file ./Dockerfile.cross . \
109
- --tag ${IMAGE_NAME}:${VERSION}-${SHORT_ARCH}${VERSION_SUFFIX}${MODERNITY_SUFFIX}${FEATURE_SUFFIX} \
110
- --provenance=false \
111
- --push
101
+
102
+ - name : Install QEMU
103
+ if : env.SELF_HOSTED_RUNNERS == 'false'
104
+ run : sudo apt-get update && sudo apt-get install -y qemu-user-static
105
+
106
+ - name : Set up Docker Buildx
107
+ if : env.SELF_HOSTED_RUNNERS == 'false'
108
+ uses : docker/setup-buildx-action@v2
109
+
110
+ - name : Build and push
111
+ uses : docker/build-push-action@v4
112
+ with :
113
+ file : ./Dockerfile.cross
114
+ context : .
115
+ platforms : linux/${{ env.SHORT_ARCH }}
116
+ push : true
117
+ tags : ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}${{ env.MODERNITY_SUFFIX }}${{ env.FEATURE_SUFFIX }}
118
+
112
119
build-docker-multiarch :
113
120
name : build-docker-multiarch${{ matrix.modernity }}
114
121
runs-on : ubuntu-22.04
@@ -117,21 +124,23 @@ jobs:
117
124
matrix :
118
125
modernity : ["", "-modern"]
119
126
env :
120
- # We need to enable experimental docker features in order to use `docker manifest`
121
- DOCKER_CLI_EXPERIMENTAL : enabled
122
127
VERSION : ${{ needs.extract-version.outputs.VERSION }}
123
128
VERSION_SUFFIX : ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
124
129
steps :
130
+ - name : Set up Docker Buildx
131
+ uses : docker/setup-buildx-action@v2
132
+
125
133
- name : Dockerhub login
126
134
run : |
127
135
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
136
+
128
137
- name : Create and push multiarch manifest
129
138
# FIXME(sproul): Fix ARM builds and put this back
130
- # --amend ${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \
139
+ # ${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \
131
140
run : |
132
- docker manifest create ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \
133
- --amend ${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }};
134
- docker manifest push ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }}
141
+ docker buildx imagetools create -t ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \
142
+ ${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }};
143
+
135
144
build-docker-lcli :
136
145
runs-on : ubuntu-22.04
137
146
needs : [extract-version]
0 commit comments