Skip to content

Commit e00ddf5

Browse files
Docker build (#486)
Closes GRAPH-1184 - Publish amd64 and arm64 docker images on pushes to main and tags - Build binaries using beefy org runners - Upgrade actionlint and perform necessary configuration and update steps to make it happy
1 parent cc64149 commit e00ddf5

File tree

6 files changed

+211
-37
lines changed

6 files changed

+211
-37
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/.git
2+
bazel-*

.github/actionlint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Configuration related to self-hosted runner.
2+
self-hosted-runner:
3+
# Labels of self-hosted runner in array of strings.
4+
labels:
5+
- ubuntu-22.04-32core-graph-team-amd64
6+
- ubuntu-22.04-32core-graph-team-arm64

.github/workflows/release-docker.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: "Release Docker images"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags:
7+
- "v*"
8+
env:
9+
REGISTRY_IMAGE: sourcegraph/scip-clang
10+
11+
jobs:
12+
build-binaries:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-22.04-32core-graph-team-amd64
18+
platform: linux/amd64
19+
binary-name: scip-clang-x86_64-linux
20+
- os: ubuntu-22.04-32core-graph-team-arm64
21+
platform: linux/arm64
22+
binary-name: scip-clang-arm64-linux
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: bazel-contrib/setup-bazel@0.14.0
28+
with:
29+
bazelisk-cache: true
30+
disk-cache: ${{ github.workflow }}-${{ matrix.binary-name }}
31+
repository-cache: true
32+
33+
- name: Build binary
34+
run: bazel build //indexer:scip-clang --config release
35+
36+
- name: Upload artifacts
37+
uses: actions/upload-artifact@v4
38+
with:
39+
path: bazel-bin/indexer/scip-clang
40+
name: ${{ matrix.binary-name }}
41+
if-no-files-found: error
42+
43+
build-docker:
44+
needs: [build-binaries]
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
include:
49+
- os: ubuntu-22.04
50+
platform: linux/amd64
51+
binary-name: scip-clang-x86_64-linux
52+
- os: ubuntu-22.04-arm
53+
platform: linux/arm64
54+
binary-name: scip-clang-arm64-linux
55+
runs-on: ${{ matrix.os }}
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Prepare
60+
run: |
61+
platform=${{ matrix.platform }}
62+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
63+
64+
- name: Docker meta
65+
id: meta
66+
uses: docker/metadata-action@v5
67+
with:
68+
images: ${{ env.REGISTRY_IMAGE }}
69+
70+
- name: Login to Docker Hub
71+
uses: docker/login-action@v3
72+
with:
73+
username: ${{ secrets.DOCKER_USERNAME }}
74+
password: ${{ secrets.DOCKER_PASSWORD }}
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v3
78+
79+
- name: Download pre-built binary
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: ${{ matrix.binary-name }}
83+
path: /tmp/binary
84+
85+
- run: cp /tmp/binary/scip-clang ./scip-clang && ls -l ./scip-clang
86+
87+
- name: Build and push by digest
88+
id: build-images
89+
uses: docker/build-push-action@v6
90+
with:
91+
context: .
92+
platforms: ${{ matrix.platform }}
93+
labels: ${{ steps.meta.outputs.labels }}
94+
tags: ${{ env.REGISTRY_IMAGE }}
95+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
96+
97+
- name: Export digest
98+
run: |
99+
mkdir -p ${{ runner.temp }}/digests
100+
digest="${{ steps.build-images.outputs.digest }}"
101+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
102+
103+
- name: Upload digest
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: digests-${{ env.PLATFORM_PAIR }}
107+
path: ${{ runner.temp }}/digests/*
108+
if-no-files-found: error
109+
retention-days: 1
110+
111+
merge-docker:
112+
runs-on: ubuntu-latest
113+
needs: [build-docker]
114+
steps:
115+
- name: Download digests
116+
uses: actions/download-artifact@v4
117+
with:
118+
path: ${{ runner.temp }}/digests
119+
pattern: digests-*
120+
merge-multiple: true
121+
122+
- name: Login to Docker Hub
123+
uses: docker/login-action@v3
124+
with:
125+
username: ${{ secrets.DOCKER_USERNAME }}
126+
password: ${{ secrets.DOCKER_PASSWORD }}
127+
128+
- name: Set up Docker Buildx
129+
uses: docker/setup-buildx-action@v3
130+
131+
- name: Snapshot metadata
132+
if: github.ref == 'refs/heads/main'
133+
uses: docker/metadata-action@v5
134+
with:
135+
images: |
136+
${{ env.REGISTRY_IMAGE }}
137+
tags: |
138+
type=raw,value=latest-snapshot
139+
140+
- name: Tag metadata
141+
if: startsWith(github.ref, 'refs/tags/v')
142+
uses: docker/metadata-action@v5
143+
with:
144+
images: |
145+
${{ env.REGISTRY_IMAGE }}
146+
tags: |
147+
type=raw,value=latest
148+
type=raw,value=${{ env.PATCH }}
149+
type=raw,value=${{ env.MINOR }}
150+
type=raw,value=${{ env.MAJOR }}
151+
152+
- name: Create manifest list and push
153+
working-directory: ${{ runner.temp }}/digests
154+
run: |
155+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
156+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

.github/workflows/release.yml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@ name: Release
22
on:
33
push:
44
tags:
5-
- 'v*'
5+
- "v*"
66
workflow_dispatch:
77
inputs:
88
revision:
9-
description: 'Tag or revision to build binaries for'
9+
description: "Tag or revision to build binaries for"
1010
type: string
1111
required: true
1212
create_release:
13-
description: 'Should publish the binary or not'
13+
description: "Should publish the binary or not"
1414
required: true
15-
default: 'false'
15+
default: "false"
1616

1717
jobs:
1818
build-and-upload-artifacts:
19-
name: 'Build and upload artifacts'
19+
name: "Build and upload artifacts"
2020
strategy:
2121
matrix:
2222
include:
23-
- platform: 'ubuntu-22.04'
24-
container: 'gcc:9.5.0-buster'
25-
config: 'dev'
26-
- platform: 'ubuntu-22.04'
27-
container: 'gcc:9.5.0-buster'
28-
config: 'release'
23+
- platform: "ubuntu-22.04"
24+
container: "gcc:9.5.0-buster"
25+
config: "dev"
26+
- platform: "ubuntu-22.04"
27+
container: "gcc:9.5.0-buster"
28+
config: "release"
2929
# macOS 14 => arm64
30-
- platform: 'macos-14'
31-
container: ''
32-
config: 'release'
30+
- platform: "macos-14"
31+
container: ""
32+
config: "release"
3333
runs-on: ${{ matrix.platform }}
3434
container: ${{ matrix.container }}
3535
env:
3636
TAG: ${{ github.event.ref }}
3737
permissions:
38-
contents: 'read'
39-
id-token: 'write'
38+
contents: "read"
39+
id-token: "write"
4040
defaults:
4141
run:
4242
shell: bash
4343
steps:
44-
- uses: actions/checkout@v3
45-
- name: '📝 Check version'
44+
- uses: actions/checkout@v4
45+
- name: "📝 Check version"
4646
run: |
4747
set -euo pipefail
4848
if [[ "${TAG:-}" == v* ]]; then
@@ -51,7 +51,7 @@ jobs:
5151
TAG_LIKE="$(grep '## v' CHANGELOG.md | head -n 1 | cut -d ' ' -f 2)"
5252
fi
5353
NEW_VERSION="${TAG_LIKE/v/}" ./tools/version_check.sh
54-
- name: '🐍 Install Bazelisk'
54+
- name: "🐍 Install Bazelisk"
5555
run: |
5656
if ! command -v bazelisk; then
5757
if [ "$RUNNER_OS" == "Windows" ]; then
@@ -64,13 +64,13 @@ jobs:
6464
fi
6565
fi
6666
- id: auth
67-
name: '🔓 Authenticate to Google Cloud'
68-
uses: 'google-github-actions/auth@v1'
67+
name: "🔓 Authenticate to Google Cloud"
68+
uses: "google-github-actions/auth@v2"
6969
with:
7070
workload_identity_provider: ${{ secrets.GCP_IDENTITY_PROVIDER }}
7171
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
7272
create_credentials_file: true
73-
- name: '🚧 Build scip-clang'
73+
- name: "🚧 Build scip-clang"
7474
run: |
7575
# Stop Windows from converting the // to /
7676
# https://github.com/bazelbuild/bazel/commit/866ecc8c3d5e0b899e3f0c9c6b2265f16daae842
@@ -99,7 +99,7 @@ jobs:
9999
fi
100100
env:
101101
CONFIG: ${{ matrix.config }}
102-
- name: '🔎 Identify OS'
102+
- name: "🔎 Identify OS"
103103
run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
104104
# - name: '🪵 Upload log'
105105
# uses: actions/upload-artifact@v3
@@ -120,19 +120,19 @@ jobs:
120120
OS: ${{ env.OS }}
121121
CONFIG: ${{ matrix.config }}
122122
- name: ${{ format('📦 Store binary ({0})', matrix.config) }}
123-
uses: actions/upload-artifact@v3
123+
uses: actions/upload-artifact@v4
124124
with:
125125
name: ${{ matrix.platform }}-${{ matrix.config }}-release-artifacts
126126
path: ${{ env.outBinaryPath }}
127127

128128
create-release:
129-
name: 'Create release'
129+
name: "Create release"
130130
if: github.event_name != 'workflow_dispatch' || inputs.create_release
131131
needs: build-and-upload-artifacts
132-
runs-on: 'ubuntu-20.04'
132+
runs-on: "ubuntu-20.04"
133133
steps:
134-
- uses: actions/checkout@v3
135-
- name: '📝 Create Release'
134+
- uses: actions/checkout@v4
135+
- name: "📝 Create Release"
136136
run: |
137137
REV="$INPUT_REVISION"
138138
if [ "$TRIGGER" != "workflow_dispatch" ]; then
@@ -147,9 +147,9 @@ jobs:
147147
INPUT_REVISION: ${{ inputs.revision }}
148148
# Download everything to avoid spelling out the different
149149
# platforms here.
150-
- name: '📥 Download all artifacts'
151-
uses: actions/download-artifact@v3
152-
- name: '📤 Upload artifacts for release'
150+
- name: "📥 Download all artifacts"
151+
uses: actions/download-artifact@v4
152+
- name: "📤 Upload artifacts for release"
153153
run: gh release upload "${GITHUB_REF/refs\/tags\//}" ./*-release-artifacts/*
154154
env:
155155
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ubuntu:22.04 as indexer
2+
3+
RUN apt-get update && apt-get install -y curl libc6-dev python3 build-essential ninja-build git cmake
4+
5+
COPY ./scip-clang /usr/bin/scip-clang
6+
RUN chmod +x /usr/bin/scip-clang && chown $(whoami) /usr/bin/scip-clang
7+
8+
WORKDIR /sources
9+
10+
ENTRYPOINT [ "scip-clang" ]

fetch_deps.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,22 @@ def fetch_direct_dependencies():
210210
http_archive(
211211
name = "actionlint_darwin_arm64",
212212
build_file = "@scip_clang//third_party:actionlint.BUILD",
213-
sha256 = "4b8eff986643b8d9918c4fd3ada9c0eee7e59230a53a46a9bd9686521dcad170",
214-
urls = ["https://github.com/rhysd/actionlint/releases/download/v1.6.27/actionlint_1.6.27_darwin_arm64.tar.gz"],
213+
sha256 = "2693315b9093aeacb4ebd91a993fea54fc215057bf0da2659056b4bc033873db",
214+
urls = ["https://github.com/rhysd/actionlint/releases/download/v1.7.7/actionlint_1.7.7_darwin_arm64.tar.gz"],
215215
)
216216

217217
http_archive(
218218
name = "actionlint_linux_amd64",
219219
build_file = "@scip_clang//third_party:actionlint.BUILD",
220-
sha256 = "5c9b6e5418f688b7f7c7e3d40c13d9e41b1ca45fb6a2c35788b0580e34b7300f",
221-
urls = ["https://github.com/rhysd/actionlint/releases/download/v1.6.27/actionlint_1.6.27_linux_amd64.tar.gz"],
220+
sha256 = "023070a287cd8cccd71515fedc843f1985bf96c436b7effaecce67290e7e0757",
221+
urls = ["https://github.com/rhysd/actionlint/releases/download/v1.7.7/actionlint_1.7.7_linux_amd64.tar.gz"],
222222
)
223223

224224
http_archive(
225225
name = "actionlint_linux_arm64",
226226
build_file = "@scip_clang//third_party:actionlint.BUILD",
227-
sha256 = "03ffe5891da7800ec39533543667697b5c292d0ff8b906397b43c58374ec052a",
228-
urls = ["https://github.com/rhysd/actionlint/releases/download/v1.6.27/actionlint_1.6.27_linux_arm64.tar.gz"],
227+
sha256 = "401942f9c24ed71e4fe71b76c7d638f66d8633575c4016efd2977ce7c28317d0",
228+
urls = ["https://github.com/rhysd/actionlint/releases/download/v1.7.7/actionlint_1.7.7_linux_arm64.tar.gz"],
229229
)
230230

231231
http_archive(

0 commit comments

Comments
 (0)