-
Notifications
You must be signed in to change notification settings - Fork 232
142 lines (139 loc) · 4.77 KB
/
docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Docker Build
on:
push:
branches:
- master
- '*docker*'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # Semver matching pattern with optional suffix
permissions:
packages: write
jobs:
build:
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
image_type:
- worker
- services
- compiler
- single
include:
- platform: linux/amd64
mold_arch: x86_64
proto_arch: x86_64
prom_arch: amd64
runs_on: buildjet-8vcpu-ubuntu-2204
- platform: linux/arm64
mold_arch: aarch64
proto_arch: aarch_64
prom_arch: arm64
runs_on: buildjet-8vcpu-ubuntu-2204-arm
- image_type: worker
dockerfile: docker/cluster/worker/Dockerfile
- image_type: services
dockerfile: docker/cluster/services/Dockerfile
- image_type: compiler
dockerfile: docker/cluster/compiler/Dockerfile
- image_type: single
dockerfile: docker/single/Dockerfile
runs-on: ${{ matrix.runs_on }}
steps:
# Get the repository's code
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: arroyo-docker # you'll use this in the next step
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/arroyosystems/arroyo-${{ matrix.image_type }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
flavor: |
latest=false
prefix=${{ matrix.prom_arch }}-
- name: Set env
run: echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platform }}
build-args: |
MOLD_ARCH=${{ matrix.mold_arch }}
PROTO_ARCH=${{ matrix.proto_arch }}
PROM_ARCH=${{ matrix.prom_arch }}
GIT_SHA=${{ env.GIT_SHA }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.arroyo-docker.outputs.tags }}
labels: ${{ steps.arroyo-docker.outputs.labels }}
manifest:
needs: build
strategy:
matrix:
image_type:
- worker
- services
- compiler
- single
runs-on: ubuntu-latest
steps:
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: arroyo-docker # you'll use this in the next step
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/arroyosystems/arroyo-${{ matrix.image_type }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Create and push Docker manifest
run: |
TAG=${{ steps.arroyo-docker.outputs.version }}
IMAGE=ghcr.io/arroyosystems/arroyo-${{ matrix.image_type }}
docker manifest create ${IMAGE}:${TAG} ${IMAGE}:arm64-${TAG} ${IMAGE}:amd64-${TAG}
docker manifest annotate ${IMAGE}:${TAG} ${IMAGE}:arm64-${TAG} --arch arm64
docker manifest annotate ${IMAGE}:${TAG} ${IMAGE}:amd64-${TAG} --arch amd64
docker manifest push ${IMAGE}:${TAG}
- name: Push latest to tip tag.
if: github.ref == 'refs/heads/master'
run: |
TAG=${{ steps.arroyo-docker.outputs.version }}
IMAGE=ghcr.io/arroyosystems/arroyo-${{ matrix.image_type }}
docker manifest create ${IMAGE}:tip ${IMAGE}:arm64-${TAG} ${IMAGE}:amd64-${TAG}
docker manifest annotate ${IMAGE}:tip ${IMAGE}:arm64-${TAG} --arch arm64
docker manifest annotate ${IMAGE}:tip ${IMAGE}:amd64-${TAG} --arch amd64
docker manifest push ${IMAGE}:tip