-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
99 lines (74 loc) · 3.51 KB
/
Justfile
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
# Copyright (c) 2024 Ho Kim (ho.kim@ulagbulag.io). All rights reserved.
# Use of this source code is governed by a GPL-3-style license that can be
# found in the LICENSE file.
# Load environment variables
set dotenv-load
# Configure environment variables
export DEBIAN_IMAGE := env_var_or_default('DEBIAN_IMAGE', 'docker.io/library/debian')
export DEBIAN_VERSION := env_var_or_default('DEBIAN_VERSION', 'bookworm')
export NGINX_IMAGE := env_var_or_default('NGINX_VERSION', "docker.io/library/nginx")
export NGINX_VERSION := env_var_or_default('NGINX_VERSION', "stable")
export NODE_IMAGE := env_var_or_default('NGINX_VERSION', "docker.io/library/node")
export NODE_VERSION := env_var_or_default('NGINX_VERSION', "22")
export RUST_IMAGE := env_var_or_default('RUST_IMAGE', "docker.io/library/rust")
export RUST_VERSION := env_var_or_default('RUST_VERSION', "1")
export OCI_BUILD_LOG_DIR := env_var_or_default('OCI_BUILD_LOG_DIR', './logs/')
export OCI_IMAGE := env_var_or_default('OCI_IMAGE', 'quay.io/ulagbulag/cassette')
export OCI_IMAGE_VERSION := env_var_or_default('OCI_IMAGE_VERSION', 'latest')
export OCI_PLATFORMS := env_var_or_default('OCI_PLATFORMS', 'linux/arm64,linux/amd64')
default: run
fmt:
cargo fmt --all
clippy: fmt
cargo clippy --package cassette --target wasm32-unknown-unknown -- -D warnings
cargo clippy --package cassette-gateway --package cassette-operator -- -D warnings
test: clippy
cargo test --all
init:
@# Node
@which npm >/dev/null 2>/dev/null || ( echo >&2 'Error: node.js is not installed' && exit 1 )
@test -d node_modules || npm clean-install
@# Rust
@which rustup >/dev/null 2>/dev/null || ( echo >&2 'Error: rustup is not installed' && exit 1 )
@rustup target list | grep wasm32-unknown-unknown | grep -q '(installed)' || rustup target add wasm32-unknown-unknown
@# Rust Deny
@which cargo-deny >/dev/null || cargo install cargo-deny
@# Rust Mobile
@which cargo-mobile >/dev/null || cargo install cargo-mobile2
@# Rust Trunk
@which trunk >/dev/null || cargo install trunk
@which wasm-bindgen >/dev/null || cargo install wasm-bindgen-cli
@# Rust Watch
@which cargo-watch >/dev/null || cargo install cargo-watch
_trunk command *ARGS: init
trunk "{{ command }}" {{ ARGS }}
check: init
cargo deny check --show-stats
build *ARGS: ( _trunk "build" ARGS )
run *ARGS: ( _trunk "serve" ARGS )
run-examples *ARGS: ( _trunk "serve" "--features" "examples,full" ARGS )
run-gateway *ARGS:
cargo watch -s 'clear && cargo run --package cassette-gateway -- {{ ARGS }}'
run-operator *ARGS:
cargo watch -s 'clear && cargo run --package cassette-operator -- {{ ARGS }}'
_oci-build file oci_suffix *ARGS:
mkdir -p "${OCI_BUILD_LOG_DIR}"
docker buildx build \
--file "{{ file }}" \
--tag "${OCI_IMAGE}{{ oci_suffix }}:${OCI_IMAGE_VERSION}" \
--build-arg DEBIAN_IMAGE="${DEBIAN_IMAGE}" \
--build-arg DEBIAN_VERSION="${DEBIAN_VERSION}" \
--build-arg NGINX_IMAGE="${NGINX_IMAGE}" \
--build-arg NGINX_VERSION="${NGINX_VERSION}" \
--build-arg NODE_IMAGE="${NODE_IMAGE}" \
--build-arg NODE_VERSION="${NODE_VERSION}" \
--build-arg RUST_IMAGE="${RUST_IMAGE}" \
--build-arg RUST_VERSION="${RUST_VERSION}" \
--platform "${OCI_PLATFORMS}" \
--pull \
{{ ARGS }} \
. 2>&1 | tee "${OCI_BUILD_LOG_DIR}/build-base-$( date -u +%s ).log"
oci-build: (_oci-build './Dockerfile' '')
oci-build-server: (_oci-build '-server' './Dockerfile.server')
oci-push: (_oci-build './Dockerfile' '' "--push")
oci-push-server: (_oci-build './Dockerfile.server' '-server' "--push")