unoverse 0.1.33 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/operator/lib/init.sh +63 -12
- package/package.json +1 -1
package/operator/lib/init.sh
CHANGED
|
@@ -5,6 +5,49 @@
|
|
|
5
5
|
# (`npm i -g unoverse`); symlinking a per-project bash script into /usr/local/bin was the
|
|
6
6
|
# second CLI we set out to delete.
|
|
7
7
|
|
|
8
|
+
# ── The image download, as an experience ─────────────────────────────────────
|
|
9
|
+
#
|
|
10
|
+
# The pull starts the moment the token is accepted, so the minute spent answering
|
|
11
|
+
# questions is also the minute the images arrive. NOTHING writes to the terminal
|
|
12
|
+
# asynchronously — a progress bar racing a readline prompt corrupts what the developer
|
|
13
|
+
# is typing. The background half writes one line of STATE to a temp file; the wizard
|
|
14
|
+
# prints a status line synchronously between question groups, where output composes
|
|
15
|
+
# with input; the end of setup attaches with docker's own bars for whatever remains.
|
|
16
|
+
PULL_STATE=""
|
|
17
|
+
start_background_pull() {
|
|
18
|
+
PULL_STATE=$(mktemp)
|
|
19
|
+
(
|
|
20
|
+
imgs=$(docker compose -f "$ROOT/docker-compose.yml" config --images 2>/dev/null | sort -u)
|
|
21
|
+
total=$(printf '%s\n' "$imgs" | grep -c .)
|
|
22
|
+
n=0
|
|
23
|
+
for img in $imgs; do
|
|
24
|
+
short="${img##*/}"; short="${short%%:*}"
|
|
25
|
+
if docker image inspect "$img" >/dev/null 2>&1; then
|
|
26
|
+
n=$((n+1)); echo "$n $total ready $short" > "$PULL_STATE"; continue
|
|
27
|
+
fi
|
|
28
|
+
echo "$n $total pulling $short" > "$PULL_STATE"
|
|
29
|
+
docker pull "$img" >/dev/null 2>&1
|
|
30
|
+
n=$((n+1)); echo "$n $total pulled $short" > "$PULL_STATE"
|
|
31
|
+
done
|
|
32
|
+
echo "$total $total done -" > "$PULL_STATE"
|
|
33
|
+
) &
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# One dim line, printed only when the wizard is printing anyway. Never a redraw.
|
|
37
|
+
pull_status_line() {
|
|
38
|
+
[ -n "$PULL_STATE" ] && [ -s "$PULL_STATE" ] || return 0
|
|
39
|
+
local n total verb what
|
|
40
|
+
read -r n total verb what < "$PULL_STATE" 2>/dev/null || return 0
|
|
41
|
+
if [ "$verb" = "done" ]; then
|
|
42
|
+
echo -e " ${GREEN}⬇${NC} ${DIM}platform images: all $total downloaded${NC}"
|
|
43
|
+
elif [ "$verb" = "pulling" ]; then
|
|
44
|
+
echo -e " ${CYAN}⬇${NC} ${DIM}platform images: $n of $total · pulling $what…${NC}"
|
|
45
|
+
else
|
|
46
|
+
echo -e " ${CYAN}⬇${NC} ${DIM}platform images: $n of $total${NC}"
|
|
47
|
+
fi
|
|
48
|
+
echo ""
|
|
49
|
+
}
|
|
50
|
+
|
|
8
51
|
# First-run detection
|
|
9
52
|
check_first_run() {
|
|
10
53
|
if [ ! -f "$ROOT/.env" ]; then
|
|
@@ -115,6 +158,18 @@ cmd_init() {
|
|
|
115
158
|
done
|
|
116
159
|
fi
|
|
117
160
|
|
|
161
|
+
# THE DOWNLOAD STARTS NOW (see the block at the top of this file).
|
|
162
|
+
if [ "$DOCKER_OK" = "1" ]; then
|
|
163
|
+
if echo "$DOCR_TOKEN" | docker login "$DOCR_REGISTRY" -u "$DOCR_TOKEN" --password-stdin >/dev/null 2>&1; then
|
|
164
|
+
start_background_pull
|
|
165
|
+
echo ""
|
|
166
|
+
echo -e " ${CYAN}⬇${NC} ${DIM}Platform images are downloading in the background while you configure${NC}"
|
|
167
|
+
echo ""
|
|
168
|
+
else
|
|
169
|
+
warn "Registry login failed with this token. Images will not pull until it is fixed"
|
|
170
|
+
fi
|
|
171
|
+
fi
|
|
172
|
+
|
|
118
173
|
# A DEFAULT, because "from your admin" is meaningless when you are the admin. The
|
|
119
174
|
# platform ships no database (docker-compose has no postgres), so this points at one
|
|
120
175
|
# you run. Enter takes the conventional local one.
|
|
@@ -144,6 +199,7 @@ cmd_init() {
|
|
|
144
199
|
fi
|
|
145
200
|
fi
|
|
146
201
|
|
|
202
|
+
pull_status_line
|
|
147
203
|
# Redis, current values as defaults
|
|
148
204
|
local rd
|
|
149
205
|
rd=$(_env_cur REDIS_HOST); rd="${rd:-host.docker.internal}"
|
|
@@ -174,7 +230,7 @@ cmd_init() {
|
|
|
174
230
|
# a deployed universe ("there is no auth-off deployment"), and the platform enforces it
|
|
175
231
|
# rather than trusting this wizard: authConfig.ts refuses to start with auth off when
|
|
176
232
|
# NODE_ENV=production. So answering "no" here cannot produce an unprotected deployment.
|
|
177
|
-
|
|
233
|
+
pull_status_line
|
|
178
234
|
local cur_auth idp_prompt
|
|
179
235
|
cur_auth=$(_env_cur AUTH_ENABLED)
|
|
180
236
|
idp_prompt="[y/N]"
|
|
@@ -243,6 +299,7 @@ cmd_init() {
|
|
|
243
299
|
ok "Redis namespace: ${BOLD}${REDIS_NAMESPACE}${NC}"
|
|
244
300
|
|
|
245
301
|
# OpenAI (for Memory Server)
|
|
302
|
+
pull_status_line
|
|
246
303
|
local cur_oai
|
|
247
304
|
cur_oai=$(_env_cur OPENAI_API_KEY)
|
|
248
305
|
# NOT just the memory server: compose hands this to the unoverse service itself —
|
|
@@ -297,21 +354,15 @@ ENVEOF
|
|
|
297
354
|
|
|
298
355
|
ok ".env created"
|
|
299
356
|
|
|
300
|
-
#
|
|
301
|
-
#
|
|
357
|
+
# Attach to the background pull started when the token was accepted: layers already
|
|
358
|
+
# down show as complete, the rest stream docker's progress bars. Without a daemon the
|
|
359
|
+
# token is in .env, and `unoverse start` pulls on its first run.
|
|
302
360
|
if [ "$DOCKER_OK" = "1" ]; then
|
|
303
|
-
echo ""
|
|
304
|
-
echo -e " Logging in to DigitalOcean Container Registry..."
|
|
305
|
-
if echo "$DOCR_TOKEN" | docker login "$DOCR_REGISTRY" -u "$DOCR_TOKEN" --password-stdin &>/dev/null; then
|
|
306
|
-
ok "Logged in to DOCR"
|
|
307
|
-
else
|
|
308
|
-
fail "DOCR login failed. Check your token"
|
|
309
|
-
exit 1
|
|
310
|
-
fi
|
|
311
361
|
pull_missing_images
|
|
362
|
+
[ -n "$PULL_STATE" ] && rm -f "$PULL_STATE"
|
|
312
363
|
else
|
|
313
364
|
echo ""
|
|
314
|
-
info "Skipped the
|
|
365
|
+
info "Skipped the image download. ${BOLD}unoverse start${NC} does it once Docker is up"
|
|
315
366
|
fi
|
|
316
367
|
|
|
317
368
|
# Install to PATH
|
package/package.json
CHANGED