-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (143 loc) · 7.61 KB
/
Copy pathMakefile
File metadata and controls
165 lines (143 loc) · 7.61 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
# Root-level entry point for common operations. Every target here
# delegates to a script/command that already exists elsewhere in this
# repo (scripts/select-and-run-eval.sh, docker-compose.yml,
# scripts/ensure-auth-data.sh, terraform/) -- this file adds no new
# logic, just a single, discoverable front door at the repo root
# instead of needing to know which script lives where.
#
# Usage:
# make help -- list targets
# make eval -- interactive model picker
# make eval MODEL=hy3 -- run a specific target directly, no menu
# make eval MODEL=hy3 DRY_RUN=1 -- print the command, don't run it
# make build -- docker-compose build (all services)
# make server-up -- start the persistent opencode server
# make server-down -- stop everything
# make server-logs -- tail the server's own logs (opencode's
# --print-logs output, mirrored to
# docker logs -- see README caveat)
# make auth -- list available provider keys (no args)
# make auth KEYS="opencode deepseek" -- extract these specific keys
# make tf-init -- terraform init (safe to re-run; cheap
# once already initialized)
# make tf-plan -- terraform plan (runs tf-init first)
# make tf-apply -- terraform apply -- interactive
# confirmation by default, same as
# running terraform directly; add
# AUTO_APPROVE=1 to skip the prompt
# make tf-destroy -- terraform destroy -- same
# confirmation behavior as tf-apply
# make tf-output -- terraform output (both next_step
# and results_dirs)
# make git-workspace -- one-shot isolated git/bash/edit
# workspace (docker-compose run --rm)
# make tf-git-workspace -- same, Terraform side
# make jupyter-up -- start the persistent Jupyter
# authoring server
# make jupyter-down -- stop it
# make jupyter-logs -- tail it (auth token appears here
# on first start)
# make tf-jupyter-up -- same, Terraform side
# make tf-jupyter-down -- same, Terraform side
.PHONY: help eval build server-up server-down server-logs auth \
tf-init tf-plan tf-apply tf-destroy tf-output tf-eval \
git-workspace tf-git-workspace jupyter-up jupyter-down jupyter-logs \
tf-jupyter-up tf-jupyter-down
help:
@echo "make eval interactive model picker"
@echo "make eval MODEL=hy3 run a specific target directly, no menu"
@echo "make eval MODEL=hy3 DRY_RUN=1 print the command, don't run it"
@echo "make build docker-compose build (all services)"
@echo "make server-up start the persistent opencode server"
@echo "make server-down stop everything"
@echo "make server-logs tail the server's own logs"
@echo "make auth list available provider keys"
@echo "make auth KEYS=\"opencode deepseek\" extract these specific keys"
@echo "make tf-init terraform init"
@echo "make tf-plan terraform plan (runs tf-init first)"
@echo "make tf-apply terraform apply (interactive confirm)"
@echo "make tf-apply AUTO_APPROVE=1 terraform apply -auto-approve"
@echo "make tf-destroy terraform destroy (interactive confirm)"
@echo "make tf-destroy AUTO_APPROVE=1 terraform destroy -auto-approve"
@echo "make tf-output terraform output"
@echo "make tf-eval cloud eval run (MODEL=provider/id, omit for live discovery, DRY_RUN=1 to preview)"
@echo "make git-workspace one-shot isolated git/bash/edit workspace"
@echo "make tf-git-workspace same, Terraform side"
@echo "make jupyter-up start the persistent Jupyter authoring server"
@echo "make jupyter-down stop it"
@echo "make jupyter-logs tail it (auth token appears here on first start)"
@echo "make tf-jupyter-up same, Terraform side"
@echo "make tf-jupyter-down same, Terraform side"
# Default OPENCODE_GLOBAL_CONFIG the same way the Terraform path already
# does (var.opencode_global_config_path's own default) -- ?= only takes
# effect if not already set from the environment or a prior assignment,
# and $(HOME) is Make's own reliable built-in, not dependent on
# docker-compose's interpolation (whose nested-default support is a v2
# feature this machine's installed 1.29.2 doesn't have).
OPENCODE_GLOBAL_CONFIG ?= $(HOME)/.config/opencode/opencode.json
export OPENCODE_GLOBAL_CONFIG
eval:
@bash scripts/select-and-run-eval.sh $(if $(DRY_RUN),--dry-run) $(MODEL)
build:
docker-compose build
server-up:
docker-compose build
docker-compose up -d server
server-down:
docker-compose down
server-logs:
@if docker inspect opencode-model-eval-server >/dev/null 2>&1; then \
docker logs -f opencode-model-eval-server; \
else \
docker-compose logs -f server; \
fi
jupyter-up:
docker-compose build jupyter
docker-compose up -d jupyter
jupyter-down:
docker-compose stop jupyter
jupyter-logs:
docker-compose logs -f jupyter
tf-jupyter-up: tf-init
cd terraform && terraform apply -target=docker_container.jupyter -target=null_resource.jupyter_connect_info
tf-jupyter-down: tf-init
cd terraform && terraform destroy -target=docker_container.jupyter
auth:
@bash scripts/ensure-auth-data.sh $(KEYS)
git-workspace:
docker-compose build git-workspace
docker-compose run --rm git-workspace
tf-git-workspace: tf-init
cd terraform && terraform apply -target=docker_container.git_workspace
tf-init:
cd terraform && terraform init
tf-plan: tf-init
cd terraform && terraform plan
# No -auto-approve by default -- same interactive confirmation you'd
# get running terraform directly, deliberately not skipped just
# because it's wrapped in a make target. AUTO_APPROVE=1 opts in
# explicitly for scripted/unattended use.
#
# Both depend on tf-init, matching tf-plan -- hit live: apply/destroy
# failing with terraform's own "Inconsistent dependency lock file"
# error (a provider required by the config with no version selected
# in the lock file) has no automatic recovery without this, since
# a plain `terraform init` (not even -upgrade) is what actually
# resolves that specific error class -- confirmed against Terraform's
# own documented dependency-installation behavior: a provider with no
# existing lock-file selection gets one added on init, no -upgrade
# needed for that case (-upgrade is only for re-resolving providers
# that already have a selection to a newer version).
tf-apply: tf-init
cd terraform && terraform apply $(if $(AUTO_APPROVE),-auto-approve)
tf-destroy: tf-init
cd terraform && terraform destroy $(if $(AUTO_APPROVE),-auto-approve)
tf-output:
cd terraform && terraform output
# Cloud eval run against Terraform-provisioned infra (server/network/
# volume must already exist -- run tf-apply first). Mirrors the `eval`
# target above exactly: MODEL is optional (omit it for live discovery
# instead of a fixed matrix entry), DRY_RUN prints the resolved docker
# commands without running them.
tf-eval:
@bash scripts/tf-select-and-run-eval.sh $(if $(DRY_RUN),--dry-run) $(MODEL)