-
Notifications
You must be signed in to change notification settings - Fork 168
232 lines (221 loc) · 7.03 KB
/
docker-image-rust-target-multi.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Build Dim Bin and Dockerize
on:
push:
branches: [ 'master', 'docker-build' ]
tags: 'v*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
create-ui:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build UI
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- run: npm install -g yarn
- run: yarn -d --cwd ui/ install
env:
NODE_OPTIONS: --openssl-legacy-provider
- run: yarn -d --cwd ui/ build
env:
NODE_OPTIONS: --openssl-legacy-provider
- name: upload ui artifacts
uses: actions/upload-artifact@v3
with:
name: ui
path: ui/build
build-armhf:
needs: [create-ui]
runs-on: ubuntu-latest
container:
image: rust:1.63
env:
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
OPENSSL_INCLUDE_DIR: "/usr/include/openssl/"
OPENSSL_LIB_DIR: "/usr/lib/arm-linux-gnueabihf/"
CARGO_TERM_COLOR: always
steps:
- name: add armhf architecture
run: dpkg --add-architecture armhf
- name: install runtime
run: apt update && apt install -y pkg-config gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross tar ca-certificates
- name: Checkout repository
uses: actions/checkout@v2
- name: Download webui
uses: actions/download-artifact@v3
with:
name: ui
path: ui/build
- uses: actions/cache@v3
with:
path: |
.cargo/bin
.cargo/registry/index
.cargo/registry/cache
.cargo/git/db
target
key: dim-bin-armhf-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
dim-bin-armhf-
- name: add armhf target
run: rustup target add armv7-unknown-linux-gnueabihf
- name: smoke test
run: rustc --version
- name: compile armhf
run: cargo build --target=armv7-unknown-linux-gnueabihf --release
- name: check path
run: ls -al target/
- name: upload armhf artifacts
uses: actions/upload-artifact@v3
with:
name: armhf-bin
path: target/armv7-unknown-linux-gnueabihf/release/dim
build-aarch64:
needs: [create-ui]
runs-on: ubuntu-latest
container:
image: rust:1.63
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
OPENSSL_INCLUDE_DIR: "/usr/include/openssl/"
OPENSSL_LIB_DIR: "/usr/lib/aarch64-linux-gnu/"
CARGO_TERM_COLOR: always
steps:
- name: add arm64 architecture
run: dpkg --add-architecture arm64
- name: install runtime
run: apt update && apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross libssl-dev:arm64
- name: Checkout repository
uses: actions/checkout@v2
- name: Download webui
uses: actions/download-artifact@v3
with:
name: ui
path: ui/build
- uses: actions/cache@v3
with:
path: |
.cargo/bin
.cargo/registry/index
.cargo/registry/cache
.cargo/git/db
target
key: dim-bin-aarch64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
dim-bin-aarch64-
- name: add arm64 target
run: rustup target add aarch64-unknown-linux-gnu
- name: smoke test
run: rustc --version
- name: compile aarch64
run: cargo build --target=aarch64-unknown-linux-gnu --release
- name: check path
run: ls -al target/
- name: upload aarch64 artifacts
uses: actions/upload-artifact@v3
with:
name: aarch64-bin
path: target/aarch64-unknown-linux-gnu/release/dim
build-amd64:
needs: [create-ui]
runs-on: ubuntu-latest
container:
image: rust:1.63
env:
CARGO_TERM_COLOR: always
steps:
- name: install runtime
run: apt update && apt install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev libssl-dev libva-dev libva-drm2 libva2
- name: Checkout repository
uses: actions/checkout@v2
- name: Download webui
uses: actions/download-artifact@v3
with:
name: ui
path: ui/build
- uses: actions/cache@v3
with:
path: |
.cargo/bin
.cargo/registry/index
.cargo/registry/cache
.cargo/git/db
target
key: dim-bin-amd64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
dim-bin-amd64-
- name: add x86_64 target
run: rustup target add x86_64-unknown-linux-gnu
- name: smoke test
run: rustc --version
- name: compile amd64
run: cargo build --features vaapi --target=x86_64-unknown-linux-gnu --release
- name: check path
run: ls -al target/
- name: upload amd64 artifacts
uses: actions/upload-artifact@v3
with:
name: amd64-bin
path: target/x86_64-unknown-linux-gnu/release/dim
build-docker-image:
needs: [build-armhf,build-aarch64,build-amd64]
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: fetch repo
uses: actions/checkout@v3
- name: Download armhf dim artifacts
uses: actions/download-artifact@v3
with:
name: armhf-bin
path: bin/armhf-bin
- name: Download armhf dim artifacts
uses: actions/download-artifact@v3
with:
name: aarch64-bin
path: bin/aarch64-bin
- name: Download amd64 dim artifacts
uses: actions/download-artifact@v3
with:
name: amd64-bin
path: bin/amd64-bin
- name: check path
run: ls -al
- name: check bin path
run: ls -al bin/
- name: setup qemu
uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
#push: true
push: ${{ github.event_name != 'pull_request' }}
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
file: ./.github/workflows/Dockerfile.ci
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha,mode=max
cache-from: type=gha