-
Notifications
You must be signed in to change notification settings - Fork 147
177 lines (158 loc) · 5.47 KB
/
build-rust-containers.yml
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Build Production Rust Containers
on:
push:
branches: [ main ]
paths:
- .github/workflows/build-rust-containers.yml
- build/containers/Dockerfile.rust
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- version.txt
pull_request:
branches: [ main ]
paths:
- .github/workflows/build-rust-containers.yml
- build/containers/Dockerfile.rust
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- version.txt
release:
types:
- published
jobs:
build-agents:
# Run separately to heat the cache for every architecture
runs-on: ubuntu-latest
timeout-minutes: 80
strategy:
matrix:
component:
- label: agent
cargo-build-args: --release
- label: agent-full
cargo-build-args: --release -F agent-full,onvif-feat,opcua-feat,udev-feat
steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Get version.txt
id: version-string
run: |
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ matrix.component.label }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.crUsername }}
password: ${{ secrets.crPassword }}
- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/project-akri/akri/${{ matrix.component.label }}
labels: |
org.opencontainers.image.title=akri-${{matrix.component.label}}
tags: |
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=raw,value=v${{steps.version-string.outputs.version}}-dev,enable=${{github.event_name != 'release'}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
build-args: |
AKRI_COMPONENT=agent
EXTRA_CARGO_ARGS=${{matrix.component.cargo-build-args}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: build/containers/Dockerfile.rust
platforms: linux/amd64,linux/arm64,linux/arm/v7
# This ensures we don't end-up with an ever-growing cache
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-others:
runs-on: ubuntu-latest
needs: build-agents
timeout-minutes: 50
strategy:
matrix:
component:
- label: controller
- label: webhook-configuration
- label: debug-echo-discovery-handler
- label: udev-discovery-handler
- label: opcua-discovery-handler
- label: onvif-discovery-handler
- label: udev-video-broker
steps:
- name: Checkout the head commit of the branch
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Get version.txt
id: version-string
run: |
echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
echo "component_tag=$(echo "${{ matrix.component.label }}" | sed 's/-handler$//')" >> $GITHUB_OUTPUT
- name: Cache Docker layers
uses: actions/cache/restore@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-agent
fail-on-cache-miss: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.crUsername }}
password: ${{ secrets.crPassword }}
- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/project-akri/akri/${{steps.version-string.outputs.component_tag}}
labels: |
org.opencontainers.image.title=akri-${{matrix.component.label}}
tags: |
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=raw,value=v${{steps.version-string.outputs.version}}-dev,enable=${{github.event_name != 'release'}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
build-args: |
AKRI_COMPONENT=${{matrix.component.label}}
EXTRA_CARGO_ARGS=--release
cache-from: type=local,src=/tmp/.buildx-cache
# No cache-to here as we want to use the one from agent
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: build/containers/Dockerfile.rust
platforms: linux/amd64,linux/arm64,linux/arm/v7