-
Notifications
You must be signed in to change notification settings - Fork 1
275 lines (230 loc) · 8.53 KB
/
Copy pathdocker.yml
File metadata and controls
275 lines (230 loc) · 8.53 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Build Docker Image
on:
push:
branches: [main]
tags: ['v*']
paths-ignore:
- 'site/**'
- 'docs/**'
- 'samples/**'
- '*.md'
- 'LICENSE'
- '.gitleaks*'
- '.github/workflows/pages.yml'
- '.github/workflows/docs.yml'
workflow_dispatch:
schedule:
# Weekly vulnerability check (Mondays 9am UTC)
- cron: '0 9 * * 1'
permissions:
contents: read
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/hone-money
jobs:
# Security scans run in parallel with each other and with builds
security-scan-rust:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: '1.92.0'
- name: Cache cargo-audit binary
id: cache-cargo-audit
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cargo/bin/cargo-audit
key: cargo-audit-0.22.0
- name: Install cargo-audit
if: steps.cache-cargo-audit.outputs.cache-hit != 'true'
run: cargo install cargo-audit --version 0.22.0 --locked
- name: Rust dependency audit
run: cargo audit
security-scan-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
sparse-checkout: |
ui/package.json
ui/package-lock.json
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
- name: Node dependency audit
working-directory: ui
run: npm audit --audit-level=high
build-backend-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: '1.92.0'
- name: Cache cargo
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-amd64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-amd64-
- name: Install OpenSSL (for SQLCipher)
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
- name: Build backend
run: cargo build --release --bin hone
- name: Set executable permission
run: chmod +x target/release/hone
- name: Upload binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: hone-x86_64-unknown-linux-gnu
path: target/release/hone
build-backend-arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: '1.92.0'
targets: aarch64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-arm64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-arm64-
- name: Install cross
run: |
if ! command -v cross &> /dev/null; then
cargo install cross --git https://github.com/cross-rs/cross --tag v0.2.5
fi
- name: Build backend
run: cross build --release --bin hone --target aarch64-unknown-linux-gnu
- name: Set executable permission
run: chmod +x target/aarch64-unknown-linux-gnu/release/hone
- name: Upload binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: hone-aarch64-unknown-linux-gnu
path: target/aarch64-unknown-linux-gnu/release/hone
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Install dependencies
working-directory: ui
run: npm ci
- name: Build frontend
working-directory: ui
run: npm run build
- name: Upload frontend
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: frontend-dist
path: ui/dist
build-image:
# Wait for all builds AND security scans before pushing
needs: [security-scan-rust, security-scan-node, build-backend-amd64, build-backend-arm64, build-frontend]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
security-events: write
actions: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download AMD64 binary
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: hone-x86_64-unknown-linux-gnu
path: ./binaries/amd64
- name: Download ARM64 binary
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: hone-aarch64-unknown-linux-gnu
path: ./binaries/arm64
- name: Download frontend
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: frontend-dist
path: ./ui/dist
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to GHCR
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Set binary permissions
run: |
chmod +x binaries/amd64/hone
chmod +x binaries/arm64/hone
- name: Build image (amd64 for scanning)
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
file: Dockerfile.release
platforms: linux/amd64
load: true
tags: ${{ env.IMAGE_NAME }}:scan
- name: Scan image for vulnerabilities
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.IMAGE_NAME }}:scan
format: 'table'
severity: 'CRITICAL,HIGH'
trivyignores: .trivyignore
exit-code: '1'
- name: Full vulnerability report (check for newly fixed CVEs)
if: github.event_name == 'schedule'
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.IMAGE_NAME }}:scan
format: 'table'
severity: 'CRITICAL,HIGH'
- name: Build and push (multi-arch)
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
file: Dockerfile.release
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}