-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
387 lines (325 loc) · 14.7 KB
/
Justfile
File metadata and controls
387 lines (325 loc) · 14.7 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
set shell := ["bash", "-euo", "pipefail", "-c"]
api_dir := "backend/api"
api_justfile := "backend/api/justfile"
admin_dir := "frontend/admin-dioxus"
dotenv_bin := "dotenv"
default:
@just --list
# Docker orchestration ------------------------------------------------------
dev env='dev':
docker compose --env-file .env.{{env}} --profile services --profile storage up -d
just storage-init {{env}}
dev-full env='dev':
docker compose --env-file .env.{{env}} --profile full --profile storage up -d --build
just storage-init {{env}}
stage:
just dev-full env=stage
prod:
just dev-full env=prod
storage-init env='dev':
scripts/rustfs-bootstrap.sh .env.{{env}}
storage-console env='dev':
@echo "RustFS Console: http://localhost:$(grep RUSTFS_CONSOLE_PORT .env.{{env}} | cut -d= -f2)"
storage-reset env='dev':
docker compose --env-file .env.{{env}} stop rustfs
docker volume rm -f $(grep PROJECT .env.{{env}} | cut -d= -f2)_rustfs_data || true
just storage-init {{env}}
logs env='dev':
docker compose --env-file .env.{{env}} logs -f
ps env='dev':
docker compose --env-file .env.{{env}} ps
down env='dev':
scripts/compose-down.sh .env.{{env}}
reset env='dev':
scripts/compose-down.sh .env.{{env}} --volumes
# Database helpers ----------------------------------------------------------
test-db env='test':
scripts/test-db-setup.sh .env.{{env}}
# Backend API (Axum) --------------------------------------------------------
# Delegate any command to the backend API justfile
api cmd env='dev' *args='':
{{dotenv_bin}} -e .env.{{env}} -- just -f {{api_justfile}} {{cmd}} {{args}}
api-dev env='dev':
just dev {{env}}
{{dotenv_bin}} -e .env.{{env}} -- just -f {{api_justfile}} dev
tui env='dev' *args='':
cd {{api_dir}} && set -a && source ../../.env.{{env}} && set +a && cargo run --bin ruxlog_tui -- {{args}}
# Frontend (Dioxus) ---------------------------------------------------------
[private]
_fe app cmd env:
#!/usr/bin/env bash
set -euo pipefail
dir="frontend/{{app}}-dioxus"
case "{{cmd}}" in
dev) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- bash -c 'dx serve --platform web --port ${{uppercase(app)}}_PORT' ;;
desktop) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- bash -c 'dx serve --platform desktop --port ${{uppercase(app)}}_PORT' ;;
desktop-native) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- bash -c 'dx serve --platform desktop --renderer native --port ${{uppercase(app)}}_PORT' ;;
mobile) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- bash -c 'dx serve --platform android --port ${{uppercase(app)}}_PORT' ;;
mobile-native) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- bash -c 'dx serve --platform android --renderer native --port ${{uppercase(app)}}_PORT' ;;
build) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx build --platform web --release ;;
build-desktop) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx build --platform desktop --release ;;
build-desktop-native) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx build --platform desktop --renderer native --release ;;
build-mobile) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx build --platform android --release ;;
build-mobile-native) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx build --platform android --renderer native --release ;;
bundle) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx bundle --platform web --release ;;
bundle-desktop) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx bundle --platform desktop --release ;;
bundle-mobile) cd "$dir" && {{dotenv_bin}} -e "../../.env.{{env}}" -- dx bundle --platform android --release ;;
tailwind) cd "$dir" && bun run tailwind ;;
tailwind-build) cd "$dir" && bun run tailwind:build ;;
install) {{dotenv_bin}} -e ".env.{{env}}" -- bash -lc "cd '$dir' && bun install" ;;
clean) {{dotenv_bin}} -e ".env.{{env}}" -- bash -lc "cd '$dir' && cargo clean" ;;
*) echo "Unknown frontend command: {{cmd}}" && exit 1 ;;
esac
# Admin frontend
admin cmd='dev' env='dev':
just _fe admin {{cmd}} {{env}}
# Consumer frontend
consumer cmd='dev' env='dev':
just _fe consumer {{cmd}} {{env}}
# Consumer static demo SSG builds (public routes + markdown content)
consumer-demo-build env='dev' base_path='/':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
base_path_arg="{{base_path}}"
base_path_arg="${base_path_arg#base_path=}"
cd frontend/consumer-dioxus
BASE_PATH_OVERRIDE="$base_path_arg" {{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc '
set -euo pipefail
base_path="${CONSUMER_BASE_PATH:-$BASE_PATH_OVERRIDE}"
unset PORT
dx build \
--fullstack \
--ssg \
--release \
--no-default-features \
--base-path "$base_path" \
@client --platform web --features "web demo-static-content basic analytics" \
@server --platform server --features "server demo-static-content basic analytics"
# dx can leave root index.html as a shell page even when SSG renders "/".
# Regenerate "/" HTML from the built server so static hosting hydrates correctly.
out_root="target/dx/consumer-dioxus/release/web"
server_bin="$out_root/consumer-dioxus"
public_dir="$out_root/public"
root_html="$public_dir/index.html"
if [ -x "$server_bin" ]; then
tmp_html="$(mktemp)"
ssg_pid=""
cleanup_root_render() {
if [ -n "$ssg_pid" ]; then
kill "$ssg_pid" >/dev/null 2>&1 || true
wait "$ssg_pid" 2>/dev/null || true
fi
rm -f "$tmp_html"
}
trap cleanup_root_render EXIT
PORT=39999 "$server_bin" >/tmp/consumer_demo_root_ssg.log 2>&1 &
ssg_pid=$!
for _ in $(seq 1 100); do
if curl -fsS "http://127.0.0.1:39999/" -o "$tmp_html"; then
mv "$tmp_html" "$root_html"
tmp_html=""
break
fi
sleep 0.1
done
cleanup_root_render
trap - EXIT
fi
'
consumer-demo-bundle env='dev' base_path='/':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
base_path_arg="{{base_path}}"
base_path_arg="${base_path_arg#base_path=}"
cd frontend/consumer-dioxus
BASE_PATH_OVERRIDE="$base_path_arg" {{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc '
set -euo pipefail
base_path="${CONSUMER_BASE_PATH:-$BASE_PATH_OVERRIDE}"
unset PORT
dx bundle \
--fullstack \
--ssg \
--release \
--no-default-features \
--base-path "$base_path" \
@client --platform web --features "web demo-static-content basic analytics" \
@server --platform server --features "server demo-static-content basic analytics"
# dx can leave root index.html as a shell page even when SSG renders "/".
# Regenerate "/" HTML from the built server so static hosting hydrates correctly.
out_root="target/dx/consumer-dioxus/release/web"
server_bin="$out_root/consumer-dioxus"
public_dir="$out_root/public"
root_html="$public_dir/index.html"
if [ -x "$server_bin" ]; then
tmp_html="$(mktemp)"
ssg_pid=""
cleanup_root_render() {
if [ -n "$ssg_pid" ]; then
kill "$ssg_pid" >/dev/null 2>&1 || true
wait "$ssg_pid" 2>/dev/null || true
fi
rm -f "$tmp_html"
}
trap cleanup_root_render EXIT
PORT=39999 "$server_bin" >/tmp/consumer_demo_root_ssg.log 2>&1 &
ssg_pid=$!
for _ in $(seq 1 100); do
if curl -fsS "http://127.0.0.1:39999/" -o "$tmp_html"; then
mv "$tmp_html" "$root_html"
tmp_html=""
break
fi
sleep 0.1
done
cleanup_root_render
trap - EXIT
fi
'
# Consumer native demo mode (desktop/mobile) using local markdown content
consumer-demo-desktop env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform desktop --no-default-features --features "desktop basic demo-static-content" --port ${CONSUMER_PORT}'
consumer-demo-desktop-native env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform desktop --renderer native --no-default-features --features "desktop basic demo-static-content" --port ${CONSUMER_PORT}'
consumer-demo-mobile env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform android --no-default-features --features "mobile basic demo-static-content" --port ${CONSUMER_PORT}'
consumer-demo-mobile-native env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform android --renderer native --no-default-features --features "mobile basic demo-static-content" --port ${CONSUMER_PORT}'
consumer-demo-build-desktop env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx build --platform desktop --release --no-default-features --features "desktop basic demo-static-content"
consumer-demo-build-mobile env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx build --platform android --release --no-default-features --features "mobile basic demo-static-content"
# Desktop builds (with and without native renderer)
admin-desktop env='dev':
just _fe admin desktop {{env}}
admin-desktop-native env='dev':
just _fe admin desktop-native {{env}}
consumer-desktop env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform desktop --no-default-features --features "desktop basic" --port ${CONSUMER_PORT}'
consumer-desktop-native env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform desktop --renderer native --no-default-features --features "desktop basic" --port ${CONSUMER_PORT}'
# Mobile builds (Android only - with and without native renderer)
admin-mobile env='dev':
just _fe admin mobile {{env}}
admin-mobile-native env='dev':
just _fe admin mobile-native {{env}}
consumer-mobile env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform android --no-default-features --features "mobile basic" --port ${CONSUMER_PORT}'
consumer-mobile-native env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- bash -lc 'dx serve --platform android --renderer native --no-default-features --features "mobile basic" --port ${CONSUMER_PORT}'
# Production builds for desktop and mobile
admin-build-desktop env='dev':
just _fe admin build-desktop {{env}}
admin-build-desktop-native env='dev':
just _fe admin build-desktop-native {{env}}
admin-build-mobile env='dev':
just _fe admin build-mobile {{env}}
admin-build-mobile-native env='dev':
just _fe admin build-mobile-native {{env}}
consumer-build-desktop env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx build --platform desktop --release --no-default-features --features "desktop basic"
consumer-build-desktop-native env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx build --platform desktop --renderer native --release --no-default-features --features "desktop basic"
consumer-build-mobile env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx build --platform android --release --no-default-features --features "mobile basic"
consumer-build-mobile-native env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx build --platform android --renderer native --release --no-default-features --features "mobile basic"
# Bundling for distribution
admin-bundle-desktop env='dev':
just _fe admin bundle-desktop {{env}}
admin-bundle-mobile env='dev':
just _fe admin bundle-mobile {{env}}
consumer-bundle-desktop env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx bundle --platform desktop --release --no-default-features --features "desktop basic"
consumer-bundle-mobile env='dev':
#!/usr/bin/env bash
set -euo pipefail
env_name="{{env}}"
env_name="${env_name#env=}"
cd frontend/consumer-dioxus
{{dotenv_bin}} -e "../../.env.${env_name}" -- dx bundle --platform android --release --no-default-features --features "mobile basic"
# Admin-specific recipes -----------------------------------------------------
admin-editor-build env='dev':
{{dotenv_bin}} -e .env.{{env}} -- bash -lc 'cd {{admin_dir}} && bun run editor:build'
admin-editor-watch env='dev':
{{dotenv_bin}} -e .env.{{env}} -- bash -lc 'cd {{admin_dir}} && bun run editor:watch'
admin-rpxy env='dev':
{{dotenv_bin}} -e .env.{{env}} -- bash -lc 'cd {{admin_dir}} && bun run rpxy'