-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
209 lines (191 loc) · 7.53 KB
/
justfile
File metadata and controls
209 lines (191 loc) · 7.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
# Justfile for goldenbraid
name := "goldenbraid"
namespace := "dictybase"
github_user := "sba964"
platform := "linux/amd64"
platform_multi := "linux/amd64,linux/arm64"
image := namespace + "/" + name
ghcr_image := "ghcr.io/" + image
[private]
check-kubeconfig:
@echo "Using KUBECONFIG={{ env('KUBECONFIG') }}" >&2
# Build the docker image for the target platform
build tag="latest":
docker buildx build --platform {{ platform }} -f build/package/Dockerfile.goldenbraid -t {{ image }}:{{ tag }} .
# Build and push the docker image
push tag="latest":
docker buildx build --platform {{ platform }} -f build/package/Dockerfile.goldenbraid -t {{ image }}:{{ tag }} --push .
# Build for GitHub Container Registry
build-ghcr tag="latest":
docker buildx build --platform {{ platform }} -f build/package/Dockerfile.goldenbraid -t {{ ghcr_image }}:{{ tag }} .
# Push to GitHub Container Registry
push-ghcr tag="latest":
echo $GITHUB_REGISTRY_TOKEN | docker login ghcr.io -u {{ github_user }} --password-stdin
docker buildx build --platform {{ platform }} -f build/package/Dockerfile.goldenbraid -t {{ ghcr_image }}:{{ tag }} --push .
# Build and push multi-arch image (amd64 + arm64)
push-multi tag="latest":
docker buildx build --platform {{ platform_multi }} -f build/package/Dockerfile.goldenbraid -t {{ image }}:{{ tag }} --push .
# Push multi-arch image to GitHub Container Registry
push-ghcr-multi tag="latest":
echo $GITHUB_REGISTRY_TOKEN | docker login ghcr.io -u {{ github_user }} --password-stdin
docker buildx build --platform {{ platform_multi }} -f build/package/Dockerfile.goldenbraid -t {{ ghcr_image }}:{{ tag }} --push .
# Show parameters for a Dagu workflow
dagu-params file:
#!/usr/bin/env bash
set -euo pipefail
schema=$(yq -r '.params.schema' {{ file }})
jq -r '.properties | to_entries | .[] | .key + " = " + (.value.default // "(required)" | tostring) + " # " + (.value.description // "")' "$schema"
# List images
list:
docker images | grep {{ image }}
# Run goldenbraid plasmid import job in dev cluster
run-goldenbraid tag k8s_config email k8s_namespace="dev" debug="false":
#!/usr/bin/env bash
set -euo pipefail
ttl="{{ if debug == "true" { "300" } else { "120" } }}"
gen_name="{{ if debug == "true" { "goldenbraid-plasmid-debug-" } else { "goldenbraid-plasmid-" } }}"
container_name="{{ if debug == "true" { "goldenbraid-plasmid-debug" } else { "goldenbraid-plasmid" } }}"
debug_args=""
if [ "{{ debug }}" == "true" ]; then
debug_args="- --log-level
- debug
- --log-format
- text"
fi
kubectl create -f - --kubeconfig {{ k8s_config }} -o jsonpath='{.metadata.name}' <<EOF
apiVersion: batch/v1
kind: Job
metadata:
generateName: ${gen_name}
namespace: {{ k8s_namespace }}
spec:
ttlSecondsAfterFinished: ${ttl}
template:
spec:
restartPolicy: Never
containers:
- name: ${container_name}
image: {{ ghcr_image }}:{{ tag }}
envFrom:
- secretRef:
name: minio
args:
- plasmid
- --user-email
- {{ email }}
${debug_args}
EOF
# Run goldenbraid plasmid-ontology job in dev cluster (assigns ontology term to all plasmids)
run-goldenbraid-plasmid-ontology tag k8s_config ontology_term="vector" k8s_namespace="dev" debug="false":
#!/usr/bin/env bash
set -euo pipefail
ttl="{{ if debug == "true" { "300" } else { "120" } }}"
gen_name="{{ if debug == "true" { "goldenbraid-plasmid-ontology-debug-" } else { "goldenbraid-plasmid-ontology-" } }}"
container_name="{{ if debug == "true" { "goldenbraid-plasmid-ontology-debug" } else { "goldenbraid-plasmid-ontology" } }}"
debug_args=""
if [ "{{ debug }}" == "true" ]; then
debug_args="- --log-level
- debug
- --log-format
- text"
fi
kubectl create -f - --kubeconfig {{ k8s_config }} -o jsonpath='{.metadata.name}' <<EOF
apiVersion: batch/v1
kind: Job
metadata:
generateName: ${gen_name}
namespace: {{ k8s_namespace }}
spec:
ttlSecondsAfterFinished: ${ttl}
template:
spec:
restartPolicy: Never
containers:
- name: ${container_name}
image: {{ ghcr_image }}:{{ tag }}
args:
- plasmid-ontology
- --ontology-term
- {{ ontology_term }}
${debug_args}
EOF
# Look up a GoldenBraid plasmid by exact name (uses goldenbraid-list image)
lookup-plasmid tag name k8s_namespace="dev": check-kubeconfig
#!/usr/bin/env bash
set -euo pipefail
kubectl create -f - -o jsonpath='{.metadata.name}' <<EOF
apiVersion: batch/v1
kind: Job
metadata:
generateName: goldenbraid-lookup-
namespace: {{ k8s_namespace }}
spec:
ttlSecondsAfterFinished: 120
template:
spec:
restartPolicy: Never
containers:
- name: goldenbraid-lookup
image: ghcr.io/dictybase/goldenbraid-list:{{ tag }}
env:
- name: PLASMID_NAME
value: "{{ name }}"
envFrom:
- secretRef:
name: minio
args:
- lookup
EOF
# Run goldenbraid inventory import job in dev cluster
run-goldenbraid-inventory tag k8s_config k8s_namespace="dev" debug="false":
#!/usr/bin/env bash
set -euo pipefail
ttl="{{ if debug == "true" { "300" } else { "120" } }}"
gen_name="{{ if debug == "true" { "goldenbraid-inventory-debug-" } else { "goldenbraid-inventory-" } }}"
container_name="{{ if debug == "true" { "goldenbraid-inventory-debug" } else { "goldenbraid-inventory" } }}"
debug_args=""
if [ "{{ debug }}" == "true" ]; then
debug_args="- --log-level
- debug
- --log-format
- text"
fi
kubectl create -f - --kubeconfig {{ k8s_config }} -o jsonpath='{.metadata.name}' <<EOF
apiVersion: batch/v1
kind: Job
metadata:
generateName: ${gen_name}
namespace: {{ k8s_namespace }}
spec:
ttlSecondsAfterFinished: ${ttl}
template:
spec:
restartPolicy: Never
containers:
- name: ${container_name}
image: {{ ghcr_image }}:{{ tag }}
envFrom:
- secretRef:
name: minio
args:
- inventory
${debug_args}
EOF
# Wait for a Kubernetes job to complete, fail, or detect stuck pods.
# Delegates to the k8s wait-job subcommand
wait-job name k8s_config k8s_namespace="dev" timeout="60s":
#!/usr/bin/env bash
set -euo pipefail
go run ./cmd/k8s/ wait-job --name {{ name }} --kubeconfig {{ k8s_config }} --namespace {{ k8s_namespace }} --timeout {{ timeout }}
# Get the logs for a specific job
job-logs name k8s_config k8s_namespace="dev":
#!/usr/bin/env bash
set -euo pipefail
go run ./cmd/k8s/ job-logs --name {{ name }} --kubeconfig {{ k8s_config }} --namespace {{ k8s_namespace }} --follow
# Get failure details for a job
job-debug name k8s_config k8s_namespace="dev":
#!/usr/bin/env bash
echo "--- Pod Logs ---"
go run ./cmd/k8s/ job-logs --name {{ name }} --kubeconfig {{ k8s_config }} --namespace {{ k8s_namespace }} || true
echo "--- Job Description ---"
kubectl describe job/{{ name }} --kubeconfig {{ k8s_config }} -n {{ k8s_namespace }}