Skip to content

Commit a63d043

Browse files
bussyjdOisinKyne
authored andcommitted
fix(dev): bake WalletConnect project ID into frontend dev builds
`just dev-frontend` / `dev-frontend-rebuild` build the local FE image but never passed NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID, so the dev image shipped with the wallet UI disabled even though the FE Dockerfile already consumes the arg (ARG -> ENV -> `pnpm run build`). Resolve the ID at build time (env NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID -> env WALLET_CONNECT_PROJECT_ID -> frontend repo .env.local) and pass it as a --build-arg. The ID is public by design (browsers use it to reach WalletConnect) but stays out of tracked obol-stack files. Factor the two near-identical recipes into a shared private recipe `_dev-frontend-build no_cache set_image` to avoid duplicating the resolver. Scope: local dev iteration only; the production release image is injected separately in the frontend repo's own build.
1 parent 913f878 commit a63d043

1 file changed

Lines changed: 58 additions & 16 deletions

File tree

justfile

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,71 @@ frontend_dir := env("FRONTEND_DIR", justfile_directory() / "../obol-stack-front-
4343
dev_image := "localhost:54103/obol-stack-front-end:dev"
4444

4545
# Build frontend from local source, push to local registry, and restart the pod
46-
dev-frontend:
47-
#!/usr/bin/env bash
48-
set -e
49-
echo "→ Building {{ dev_image }} from {{ frontend_dir }}"
50-
docker build -t {{ dev_image }} {{ frontend_dir }}
51-
echo "→ Pushing {{ dev_image }} to local registry"
52-
docker push {{ dev_image }}
53-
echo "→ Restarting frontend deployment"
54-
obol kubectl set image deployment/obol-frontend-obol-app \
55-
obol-app={{ dev_image }} -n obol-frontend
56-
obol kubectl rollout restart deployment/obol-frontend-obol-app -n obol-frontend
57-
obol kubectl rollout status deployment/obol-frontend-obol-app -n obol-frontend --timeout=120s
58-
echo "✓ Frontend dev build live at http://obol.stack:8080"
46+
dev-frontend: (_dev-frontend-build "false" "true")
5947

6048
# Rebuild and hot-swap frontend (skip docker cache for faster iteration)
61-
dev-frontend-rebuild:
49+
dev-frontend-rebuild: (_dev-frontend-build "true" "false")
50+
51+
# Internal: build the frontend dev image, push it, and roll out the deployment.
52+
# no_cache="true" -> docker build --no-cache (forces a clean rebuild)
53+
# set_image="true" -> repoint the deployment at the dev tag (first build);
54+
# rebuilds skip this since the tag is already wired.
55+
#
56+
# The WalletConnect project ID is baked into the Next.js client bundle at build
57+
# time (it's public by design — browsers use it to reach WalletConnect). We keep
58+
# it out of tracked obol-stack files by resolving it at build time, in order:
59+
# 1. NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID env var
60+
# 2. WALLET_CONNECT_PROJECT_ID env var
61+
# 3. the frontend repo's .env.local
62+
_dev-frontend-build no_cache set_image:
6263
#!/usr/bin/env bash
6364
set -e
64-
echo "→ Rebuilding {{ dev_image }} (no cache)"
65-
docker build --no-cache -t {{ dev_image }} {{ frontend_dir }}
65+
66+
resolve_wallet_connect_project_id() {
67+
if [ -n "${NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID:-}" ]; then
68+
printf '%s' "$NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID"
69+
return
70+
fi
71+
if [ -n "${WALLET_CONNECT_PROJECT_ID:-}" ]; then
72+
printf '%s' "$WALLET_CONNECT_PROJECT_ID"
73+
return
74+
fi
75+
76+
local env_file="{{ frontend_dir }}/.env.local"
77+
if [ -f "$env_file" ]; then
78+
local line
79+
line="$(grep -E '^(NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID|WALLET_CONNECT_PROJECT_ID)=' "$env_file" | tail -n 1 || true)"
80+
line="${line#*=}"
81+
line="${line%\"}"
82+
line="${line#\"}"
83+
printf '%s' "$line"
84+
fi
85+
}
86+
87+
build_args=()
88+
wallet_connect_project_id="$(resolve_wallet_connect_project_id)"
89+
if [ -n "$wallet_connect_project_id" ]; then
90+
echo "→ WalletConnect project ID found; baking wallet UI into the Next.js bundle"
91+
build_args+=(--build-arg "NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=$wallet_connect_project_id")
92+
else
93+
echo "→ WalletConnect project ID not found; wallet UI will be disabled"
94+
fi
95+
96+
if [ "{{ no_cache }}" = "true" ]; then
97+
echo "→ Rebuilding {{ dev_image }} (no cache) from {{ frontend_dir }}"
98+
build_args+=(--no-cache)
99+
else
100+
echo "→ Building {{ dev_image }} from {{ frontend_dir }}"
101+
fi
102+
103+
docker build "${build_args[@]}" -t {{ dev_image }} {{ frontend_dir }}
66104
echo "→ Pushing {{ dev_image }} to local registry"
67105
docker push {{ dev_image }}
68106
echo "→ Restarting frontend deployment"
107+
if [ "{{ set_image }}" = "true" ]; then
108+
obol kubectl set image deployment/obol-frontend-obol-app \
109+
obol-app={{ dev_image }} -n obol-frontend
110+
fi
69111
obol kubectl rollout restart deployment/obol-frontend-obol-app -n obol-frontend
70112
obol kubectl rollout status deployment/obol-frontend-obol-app -n obol-frontend --timeout=120s
71113
echo "✓ Frontend dev build live at http://obol.stack:8080"

0 commit comments

Comments
 (0)