-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
362 lines (310 loc) · 14.2 KB
/
Justfile
File metadata and controls
362 lines (310 loc) · 14.2 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
set shell := ["bash", "-uc"]
arch := `uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/'`
GO_VERSION := env_var_or_default("GO_VERSION", "1.25.1")
TARGETARCH := env_var_or_default("TARGETARCH", arch)
IMAGE := env_var_or_default("JUST_IMAGE", "just:latest")
CONTAINER_CMD := env_var_or_default("JUST_CONTAINER_CMD", "bash")
WASSETTE_REF := env_var_or_default("WASSETTE_REF", "main")
WASSETTE_REF_TYPE := env_var_or_default("WASSETTE_REF_TYPE", "branch")
PORT := env_var_or_default("PORT", "8080")
CONTAINER_MEMORY := env_var_or_default("CONTAINER_MEMORY", "4g")
CONTAINER_CPUS := env_var_or_default("CONTAINER_CPUS", "2")
# Path to devcontainer just directory
DEVCONTAINER_JUST := ".devcontainer/just"
export CARGO_HOME := "/home/vscode/.cargo"
export RUSTUP_HOME := "/home/vscode/.rustup"
vscode := "sudo --preserve-env=PATH --set-home --login --user vscode"
alias default := list
list:
just --list
run *recipes:
#!/usr/bin/env bash
set -euxo pipefail
for recipe in {{recipes}}; do
echo "Running recipe: $recipe"
just "$recipe"
done
setup-completions:
#!/usr/bin/env bash
set -euxo pipefail
# Setup bash completion
mkdir -p /etc/bash_completion.d
just --completions bash > /etc/bash_completion.d/just
# Setup zsh completion for vscode user
mkdir -p /home/vscode/.zsh/completion
just --completions zsh > /home/vscode/.zsh/completion/_just
chown -R vscode:vscode /home/vscode/.zsh
# Add to vscode's .zshrc if not already there
if [ -f /home/vscode/.zshrc ]; then
if ! grep -q "fpath=(.*\.zsh/completion" /home/vscode/.zshrc; then
echo 'fpath=(~/.zsh/completion $fpath)' >> /home/vscode/.zshrc
echo 'autoload -Uz compinit && compinit' >> /home/vscode/.zshrc
fi
else
echo 'fpath=(~/.zsh/completion $fpath)' > /home/vscode/.zshrc
echo 'autoload -Uz compinit && compinit' >> /home/vscode/.zshrc
chown vscode:vscode /home/vscode/.zshrc
fi
echo "Completions installed. Restart your shell or run: source ~/.bashrc (or ~/.zshrc)"
# Update apt cache (idempotent - safe to call multiple times)
# Use force=true to bypass cache check: just apt-update force=true
apt-update force="false":
#!/usr/bin/env bash
set -euxo pipefail
APT_CACHE_MARKER="/var/lib/apt/lists/lock"
# Check if apt cache exists and force is not set
if [ "{{force}}" != "true" ] && [ -f "$APT_CACHE_MARKER" ]; then
echo "apt cache already updated (found $APT_CACHE_MARKER), skipping..."
echo "Use 'just apt-update force=true' to force update"
exit 0
fi
apt-get update
# Clean up apt cache to save space
apt-cleanup:
#!/usr/bin/env bash
set -euxo pipefail
rm -rf /var/lib/apt/lists/*
install-go: apt-update
#!/usr/bin/env bash
set -euxo pipefail
GO_ARCH="$(case "{{TARGETARCH}}" in \
amd64) echo amd64 ;; \
arm64|arm64v8) echo arm64 ;; \
*) echo "Unsupported TARGETARCH: {{TARGETARCH}}" >&2; exit 1 ;; \
esac)"
apt-get install -y --no-install-recommends wget tar
rm -rf /usr/local/go
wget -q -O /tmp/go.tar.gz "https://go.dev/dl/go{{GO_VERSION}}.linux-${GO_ARCH}.tar.gz"
tar -C /usr/local -xzf /tmp/go.tar.gz
rm /tmp/go.tar.gz
/usr/local/go/bin/go version
install-rust: apt-update
#!/usr/bin/env bash
set -euxo pipefail
# Check if Rust is already installed
if {{vscode}} bash -lc 'command -v rustc && command -v cargo' &>/dev/null; then
echo "Rust is already installed, skipping..."
{{vscode}} bash -lc 'rustc --version && cargo --version'
exit 0
fi
apt-get install -y --no-install-recommends ca-certificates curl
mkdir -p {{CARGO_HOME}} {{RUSTUP_HOME}}
chown -R vscode:vscode {{CARGO_HOME}} {{RUSTUP_HOME}}
{{vscode}} bash -lc 'curl -fsSL https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable'
{{vscode}} bash -lc '. "$HOME/.cargo/env" && rustc --version && cargo --version'
install-node:
#!/usr/bin/env bash
set -euxo pipefail
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y --no-install-recommends nodejs
node --version
npm --version
install-java: apt-update
#!/usr/bin/env bash
set -euxo pipefail
apt-get install -y --no-install-recommends openjdk-21-jdk
java -version
javac -version
install-maven: install-java apt-update
#!/usr/bin/env bash
set -euxo pipefail
MAVEN_VERSION="3.9.9"
apt-get install -y --no-install-recommends wget tar
wget -q -O /tmp/maven.tar.gz "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
tar -C /opt -xzf /tmp/maven.tar.gz
ln -sf "/opt/apache-maven-${MAVEN_VERSION}/bin/mvn" /usr/local/bin/mvn
rm /tmp/maven.tar.gz
mvn --version
install-gradle: install-java apt-update
#!/usr/bin/env bash
set -euxo pipefail
GRADLE_VERSION="8.11.1"
apt-get install -y --no-install-recommends curl unzip
curl -fsSL --retry 3 --retry-delay 2 --retry-all-errors \
-o /tmp/gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip"
unzip -q /tmp/gradle.zip -d /opt
ln -sf "/opt/gradle-${GRADLE_VERSION}/bin/gradle" /usr/local/bin/gradle
rm /tmp/gradle.zip
gradle --version
configure-npm-prefix: install-node
#!/usr/bin/env bash
set -euxo pipefail
mkdir -p /home/vscode/.npm-global
chown -R vscode:vscode /home/vscode/.npm-global
printf 'export PATH="/home/vscode/.npm-global/bin:$PATH"\n' > /etc/profile.d/npm-global.sh
{{vscode}} bash -lc 'npm config set prefix ~/.npm-global'
install-azure-cli:
#!/usr/bin/env bash
set -euxo pipefail
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
az version
az bicep install
install-github-cli: apt-update
#!/usr/bin/env bash
set -euxo pipefail
apt-get install -y --no-install-recommends curl ca-certificates gnupg
mkdir -p -m 0755 /etc/apt/keyrings
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o /etc/apt/keyrings/githubcli-archive-keyring.gpg
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list
apt-get update
apt-get install -y --no-install-recommends gh
gh --version
install-homebrew: apt-update
#!/usr/bin/env bash
set -euxo pipefail
apt-get install -y --no-install-recommends build-essential procps curl file git
# Create and setup Homebrew directory with proper permissions before installation
mkdir -p /home/linuxbrew/.linuxbrew
chown -R vscode:vscode /home/linuxbrew
# Install Homebrew as vscode user without needing sudo for directory creation
{{vscode}} bash -lc 'if [ ! -d /home/linuxbrew/.linuxbrew/bin ]; then NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; fi'
{{vscode}} bash -lc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew update'
printf 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"\n' > /etc/profile.d/homebrew.sh
{{vscode}} bash -lc 'if ! grep -q "brew shellenv" ~/.bashrc; then echo "eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\"" >> ~/.bashrc; fi'
install-brew-codex: install-homebrew
{{vscode}} bash -lc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew install codex'
install-brew-opencode: install-homebrew
{{vscode}} bash -lc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew install sst/tap/opencode'
install-brew-wassette: install-homebrew
{{vscode}} bash -lc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew tap microsoft/wassette https://github.com/microsoft/wassette && brew install wassette'
install-brew-azure-cli: install-homebrew
#!/usr/bin/env bash
set -euxo pipefail
{{vscode}} bash -lc 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew install azure-cli'
{{vscode}} bash -lc 'az version'
# {{vscode}} bash -lc 'az bicep install'
install-cli-claude: configure-npm-prefix
{{vscode}} bash -lc 'npm install -g @anthropic-ai/claude-code'
install-cli-gemini: configure-npm-prefix
{{vscode}} bash -lc 'npm install -g @google/gemini-cli'
install-cli-crush: configure-npm-prefix
{{vscode}} bash -lc 'npm install -g @charmland/crush'
install-cli-copilot: configure-npm-prefix
{{vscode}} bash -lc 'npm install -g @github/copilot'
install-cli-npm: install-cli-claude install-cli-gemini install-cli-crush install-cli-copilot
@echo "All AI CLI tools installed"
install-llm: apt-update
#!/usr/bin/env bash
set -euxo pipefail
apt-get install -y --no-install-recommends python3 python3-venv python3-pip python3-dev build-essential curl git
python3 -m venv /opt/llm-env
chown -R vscode:vscode /opt/llm-env
{{vscode}} bash -lc '/opt/llm-env/bin/pip install --upgrade pip'
{{vscode}} bash -lc '/opt/llm-env/bin/pip install llm'
install-llm-plugins: install-llm
#!/usr/bin/env bash
set -euxo pipefail
{{vscode}} bash -lc '/opt/llm-env/bin/pip install llm-claude-3 llm-gemini llm-ollama llm-foundry'
install-llm-gpt4all: install-llm
#!/usr/bin/env bash
set -euxo pipefail
# Note: gpt4all may have shared library dependencies issues on some systems
{{vscode}} bash -lc '/opt/llm-env/bin/pip install llm-gpt4all'
install-wassette: install-rust apt-update
#!/usr/bin/env bash
set -euxo pipefail
apt-get install -y --no-install-recommends ca-certificates curl git build-essential pkg-config libssl-dev
{{vscode}} bash -lc '. "$HOME/.cargo/env" && CARGO_BUILD_JOBS=1 CARGO_PROFILE_RELEASE_LTO=off cargo install --git https://github.com/microsoft/wassette --{{WASSETTE_REF_TYPE}} {{WASSETTE_REF}} wassette-mcp-server && wassette --version'
install-wassette-link: install-wassette
#!/usr/bin/env bash
set -euxo pipefail
ln -sf /home/vscode/.cargo/bin/wassette /usr/local/bin/wassette
ls -la /usr/local/bin/wassette
setup-mcp-config:
#!/usr/bin/env bash
set -euxo pipefail
mkdir -p .vscode
[ -f .vscode/mcp.json ] || cp /opt/wassette/mcp.json .vscode/mcp.json
echo "MCP config installed to .vscode/mcp.json"
install-all: install-go install-rust install-node install-java install-maven install-gradle configure-npm-prefix install-github-cli install-homebrew install-brew-codex install-brew-opencode install-brew-wassette install-brew-azure-cli install-cli-npm install-llm install-llm-plugins
@echo "All components installed"
macos-build-container:
#!/usr/bin/env bash
set -euxo pipefail
# Build a container image using the container command
container system start || true
container build -t {{IMAGE}} -f {{DEVCONTAINER_JUST}}/Dockerfile --build-arg TARGETARCH={{TARGETARCH}} --build-arg GO_VERSION={{GO_VERSION}} .
macos-build-container-all:
#!/usr/bin/env bash
set -euxo pipefail
# Build a container image with all components installed
container system start || true
IMAGE_BASE="$(echo {{IMAGE}} | cut -d: -f1)"
container build -t "${IMAGE_BASE}:all" -f {{DEVCONTAINER_JUST}}/Dockerfile --build-arg TARGETARCH={{TARGETARCH}} --build-arg GO_VERSION={{GO_VERSION}} --build-arg JUST_RECIPE=install-all .
macos-run-container:
#!/usr/bin/env bash
set -euxo pipefail
# Run a container using the macOS container command
container system start || true
container run --rm -it \
--memory {{CONTAINER_MEMORY}} \
--cpus {{CONTAINER_CPUS}} \
--publish {{PORT}}:8080 \
--volume "$(pwd)":/pwd \
--workdir /pwd \
{{IMAGE}} {{CONTAINER_CMD}}
macos-stop-containers:
#!/usr/bin/env bash
set -eux
# Stop all running containers matching the configured image
container ps -q -f ancestor={{IMAGE}} | xargs -r container stop || true
docker ps -q -f ancestor={{IMAGE}} | xargs -r docker stop || true
macos-restart-containers:
#!/usr/bin/env bash
set -eux
# Restart the macOS container system
container system stop
container system start
macos-list-containers-json:
#!/usr/bin/env bash
set -eux
# List containers in JSON format, filtering by the configured image
container ls --format json | jq -c '.[] | select(.configuration.image.reference | contains("{{IMAGE}}")?)' 2>/dev/null || echo "No containers found or error parsing JSON"
macos-list-containers:
#!/usr/bin/env bash
set -eux
# Output container IDs matching the image (can be piped to container rm/kill)
container ls --format json | jq -r '.[] | select(.configuration.image.reference | contains("{{IMAGE}}")) | .configuration.id' 2>/dev/null
macos-clean-containers:
#!/usr/bin/env bash
set -eux
# Kill all containers, then remove them
just macos-list-containers | xargs -r container kill || true
just macos-list-containers | xargs -r container rm -f || true
# Docker container recipes (Linux/cross-platform)
docker-build:
docker build -t {{IMAGE}} -f {{DEVCONTAINER_JUST}}/Dockerfile --build-arg TARGETARCH={{TARGETARCH}} --build-arg GO_VERSION={{GO_VERSION}} .
docker-build-all:
#!/usr/bin/env bash
set -euxo pipefail
IMAGE_BASE="$(echo {{IMAGE}} | cut -d: -f1)"
docker build -t "${IMAGE_BASE}:all" -f {{DEVCONTAINER_JUST}}/Dockerfile --build-arg TARGETARCH={{TARGETARCH}} --build-arg GO_VERSION={{GO_VERSION}} --build-arg JUST_RECIPE=install-all .
docker-run:
docker run --rm -it \
--memory {{CONTAINER_MEMORY}} \
--cpus {{CONTAINER_CPUS}} \
-p {{PORT}}:8080 \
-v "$(pwd)":/pwd \
-w /pwd \
{{IMAGE}} {{CONTAINER_CMD}}
docker-stop:
#!/usr/bin/env bash
set -eux
# Stop all running containers matching the configured image
docker ps -q -f ancestor={{IMAGE}} | xargs -r docker stop || true
docker-restart:
#!/usr/bin/env bash
set -eux
# Restart Docker daemon
docker restart || true
docker-list:
#!/usr/bin/env bash
set -eux
# List all containers matching the configured image
docker ps -a -f ancestor={{IMAGE}}
docker-clean:
#!/usr/bin/env bash
set -eux
# Kill and remove all containers matching the configured image
docker ps -a -q -f ancestor={{IMAGE}} | xargs -r docker rm -f || true