Skip to content

Commit b27517c

Browse files
authored
Fix demo deployment workflow and CDN cache invalidation (#4857)
## Motivation The demo deployment workflow had several issues: 1. Cache invalidation was not working via CLI (wrong URL map name) 2. No way to rebuild frontends without redeploying blockchain apps (missing .env retrieval) 3. MetaMask demo deployment broken due to absolute asset paths ## Proposal **Infrastructure Fixes:** - Fixed CDN cache invalidation by using correct URL map `demos-linera-net` (was using `linera-apps-url-map` which points to different bucket) - Removed redundant confirmation prompts (deployment already asks for YES) **Workflow Improvements:** - Added `fetch-env-counter`, `fetch-env-fungible`, `fetch-env-all` targets to retrieve .env files from GCS - Updated `*-quick` deployment targets to auto-fetch .env before building frontends - Enables frontend-only updates without blockchain redeployment **Build Fixes:** - Fixed pnpm install step - Removed flawed/unneeded checks in Makefile ## Test Plan - [x] Verified cache invalidation works with correct URL map - [x] Tested `fetch-env-*` targets retrieve .env from GCS successfully - [x] Confirmed `quick-deploy` workflow: fetch .env → build → deploy → invalidate cache - [x] Manual deployment to testnet-conway demos site ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 6923600 commit b27517c

File tree

1 file changed

+41
-30
lines changed

1 file changed

+41
-30
lines changed

Makefile

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LINERA_BIN := ./target/release/linera
1111
# These defaults point to the public Linera demo infrastructure
1212
# Override these variables for private/internal deployments
1313
PUBLIC_GCS_BUCKET := gs://demos.linera.net
14-
PUBLIC_URL_MAP := linera-apps-url-map
14+
PUBLIC_URL_MAP := demos-linera-net
1515

1616
# Allow overrides for private deployments
1717
GCS_BUCKET ?= $(PUBLIC_GCS_BUCKET)
@@ -78,7 +78,7 @@ help: ## Show this help message
7878
@grep -E '^(counter-full|fungible-full|full-deploy|counter-quick|fungible-quick|quick-deploy):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(YELLOW)%-25s$(NC) %s\n", $$1, $$2}'
7979
@echo ""
8080
@printf "$(GREEN)━━━ 8. Utilities ━━━$(NC)\n"
81-
@grep -E '^(verify|invalidate-cache|create-env):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(YELLOW)%-25s$(NC) %s\n", $$1, $$2}'
81+
@grep -E '^(verify|invalidate-cache|create-env|fetch-env-counter|fetch-env-fungible|fetch-env-all):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(YELLOW)%-25s$(NC) %s\n", $$1, $$2}'
8282
@echo ""
8383
@printf "$(GREEN)━━━ 9. Cleanup ━━━$(NC)\n"
8484
@grep -E '^(clean|clean-cargo-all|clean-cargo-main|clean-cargo-counter|clean-cargo-fungible|clean-all):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(YELLOW)%-25s$(NC) %s\n", $$1, $$2}'
@@ -251,7 +251,7 @@ build-demo-counter: ## Build counter web frontend
251251
echo "LINERA_APPLICATION_ID=$$LINERA_APPLICATION_ID" > .env && \
252252
echo "LINERA_FAUCET_URL=$$LINERA_FAUCET_URL" >> .env; \
253253
fi && \
254-
pnpm install --ignore-scripts && \
254+
pnpm install && \
255255
pnpm build; \
256256
else \
257257
printf "$(YELLOW) No web interface to build for counter (using static HTML)$(NC)\n"; \
@@ -267,7 +267,7 @@ build-demo-fungible: ## Build fungible web frontend
267267
echo "LINERA_APPLICATION_ID=$$LINERA_APPLICATION_ID" > .env && \
268268
echo "LINERA_FAUCET_URL=$$LINERA_FAUCET_URL" >> .env; \
269269
fi && \
270-
pnpm install --ignore-scripts && \
270+
pnpm install && \
271271
pnpm build; \
272272
elif [ -f "$(EXAMPLES_DIR)/fungible/package.json" ]; then \
273273
cd $(EXAMPLES_DIR)/fungible && \
@@ -276,7 +276,7 @@ build-demo-fungible: ## Build fungible web frontend
276276
echo "LINERA_APPLICATION_ID=$$LINERA_APPLICATION_ID" > .env && \
277277
echo "LINERA_FAUCET_URL=$$LINERA_FAUCET_URL" >> .env; \
278278
fi && \
279-
pnpm install --ignore-scripts && \
279+
pnpm install && \
280280
pnpm build; \
281281
else \
282282
printf "$(YELLOW) No web interface to build for fungible token$(NC)\n"; \
@@ -292,10 +292,8 @@ build-demo-metamask: ## Build MetaMask web frontend
292292
echo "LINERA_APPLICATION_ID=$$LINERA_APPLICATION_ID" > .env && \
293293
echo "LINERA_FAUCET_URL=$$LINERA_FAUCET_URL" >> .env; \
294294
fi && \
295-
pnpm install --ignore-scripts && \
295+
pnpm install && \
296296
pnpm build; \
297-
elif [ -f "$(EXAMPLES_DIR)/counter/metamask/index.html" ]; then \
298-
printf "$(YELLOW) MetaMask frontend uses static HTML$(NC)\n"; \
299297
else \
300298
printf "$(YELLOW) No MetaMask frontend found$(NC)\n"; \
301299
fi
@@ -321,20 +319,45 @@ check-gcloud-auth: ## Verify gcloud authentication for GCS
321319
fi
322320
@printf "$(GREEN)✅ GCloud authentication verified$(NC)\n"
323321

322+
# ===== Fetch .env from GCS =====
323+
fetch-env-counter: check-gcloud-auth ## Fetch counter .env from GCS
324+
@printf "$(YELLOW)📥 Fetching counter .env from GCS...$(NC)\n"
325+
@if gcloud storage cp '$(DEMO_PATH)/counter/.env' .env.counter 2>/dev/null; then \
326+
printf "$(GREEN)✅ Counter .env downloaded to .env.counter$(NC)\n"; \
327+
cat .env.counter; \
328+
else \
329+
printf "$(RED)❌ Failed to fetch .env from $(DEMO_PATH)/counter/.env$(NC)\n"; \
330+
printf "$(YELLOW) Make sure the app has been deployed to GCS first$(NC)\n"; \
331+
exit 1; \
332+
fi
333+
334+
fetch-env-fungible: check-gcloud-auth ## Fetch fungible .env from GCS
335+
@printf "$(YELLOW)📥 Fetching fungible .env from GCS...$(NC)\n"
336+
@if gcloud storage cp '$(DEMO_PATH)/fungible/.env' .env.fungible 2>/dev/null; then \
337+
printf "$(GREEN)✅ Fungible .env downloaded to .env.fungible$(NC)\n"; \
338+
cat .env.fungible; \
339+
else \
340+
printf "$(RED)❌ Failed to fetch .env from $(DEMO_PATH)/fungible/.env$(NC)\n"; \
341+
printf "$(YELLOW) Make sure the app has been deployed to GCS first$(NC)\n"; \
342+
exit 1; \
343+
fi
344+
345+
fetch-env-all: fetch-env-counter fetch-env-fungible ## Fetch all .env files from GCS
346+
324347
# ===== CDN Cache Invalidation =====
325348
invalidate-cache: ## Invalidate CDN cache for a specific path
326349
@if [ -z "$(CACHE_PATH)" ]; then \
327350
printf "$(RED)❌ CACHE_PATH not specified$(NC)\n"; \
328351
printf "$(YELLOW) Usage: make invalidate-cache CACHE_PATH=/testnet/counter/*$(NC)\n"; \
329352
exit 1; \
330353
fi
331-
@printf "$(YELLOW)🔄 Do you want to invalidate CDN cache for path: $(CACHE_PATH)?$(NC)\n"
332-
@printf "Type 'YES' (all uppercase) to continue: " && read confirm && [ "$$confirm" = "YES" ] || { printf "$(RED)Cache invalidation cancelled$(NC)\n"; exit 1; }
333-
@printf "$(YELLOW)🗑️ Invalidating CDN cache...$(NC)\n"
354+
@printf "$(YELLOW)🔄 Invalidating CDN cache for path: $(CACHE_PATH)$(NC)\n"
334355
@gcloud compute url-maps invalidate-cdn-cache $(URL_MAP) \
335356
--path "$(CACHE_PATH)" \
336-
--global --async
357+
--global \
358+
--async
337359
@printf "$(GREEN)✅ Cache invalidation initiated for $(CACHE_PATH)$(NC)\n"
360+
@printf "$(BLUE) Note: Cache invalidation may take a few minutes to propagate globally$(NC)\n"
338361

339362
# ===== GCS Deployment (Per Demo) =====
340363
deploy-gcs-counter: check-gcloud-auth build-demo-counter ## Deploy counter to GCS
@@ -346,11 +369,8 @@ deploy-gcs-counter: check-gcloud-auth build-demo-counter ## Deploy counter to GC
346369
gcloud storage rsync -r --delete-unmatched-destination-objects \
347370
$(EXAMPLES_DIR)/counter/dist/ \
348371
'$(DEMO_PATH)/counter/'; \
349-
elif [ -f "$(EXAMPLES_DIR)/counter/index.html" ]; then \
350-
gcloud storage cp $(EXAMPLES_DIR)/counter/index.html '$(DEMO_PATH)/counter/index.html'; \
351-
if [ -d "$(EXAMPLES_DIR)/counter/public" ]; then \
352-
gcloud storage rsync -r $(EXAMPLES_DIR)/counter/public/ '$(DEMO_PATH)/counter/'; \
353-
fi; \
372+
else \
373+
printf "$(YELLOW) No counter demo found$(NC)\n"; \
354374
fi
355375
@if [ -f .env.counter ]; then \
356376
gcloud storage cp .env.counter '$(DEMO_PATH)/counter/.env'; \
@@ -367,14 +387,8 @@ deploy-gcs-fungible: check-gcloud-auth build-demo-fungible ## Deploy fungible to
367387
gcloud storage rsync -r --delete-unmatched-destination-objects \
368388
$(EXAMPLES_DIR)/native-fungible/dist/ \
369389
'$(DEMO_PATH)/fungible/'; \
370-
elif [ -d "$(EXAMPLES_DIR)/fungible/dist" ]; then \
371-
gcloud storage rsync -r --delete-unmatched-destination-objects \
372-
$(EXAMPLES_DIR)/fungible/dist/ \
373-
'$(DEMO_PATH)/fungible/'; \
374-
elif [ -f "$(EXAMPLES_DIR)/native-fungible/index.html" ]; then \
375-
gcloud storage cp $(EXAMPLES_DIR)/native-fungible/index.html '$(DEMO_PATH)/fungible/index.html'; \
376390
else \
377-
printf "$(YELLOW) No web interface found for fungible token$(NC)\n"; \
391+
printf "$(YELLOW) No fungible token demo found$(NC)\n"; \
378392
fi
379393
@if [ -f .env.fungible ]; then \
380394
gcloud storage cp .env.fungible '$(DEMO_PATH)/fungible/.env'; \
@@ -391,9 +405,6 @@ deploy-gcs-metamask: check-gcloud-auth build-demo-metamask ## Deploy MetaMask to
391405
gcloud storage rsync -r --delete-unmatched-destination-objects \
392406
$(EXAMPLES_DIR)/counter/metamask/dist/ \
393407
'$(DEMO_PATH)/metamask/'; \
394-
elif [ -f "$(EXAMPLES_DIR)/counter/metamask/index.html" ]; then \
395-
gcloud storage cp $(EXAMPLES_DIR)/counter/metamask/*.html '$(DEMO_PATH)/metamask/'; \
396-
gcloud storage cp $(EXAMPLES_DIR)/counter/metamask/*.js '$(DEMO_PATH)/metamask/' 2>/dev/null || true; \
397408
else \
398409
printf "$(YELLOW) No MetaMask demo found$(NC)\n"; \
399410
fi
@@ -496,9 +507,9 @@ fungible-full: setup init-wallet deploy-app-fungible deploy-gcs-fungible verify
496507
full-deploy: setup init-wallet deploy-apps-all deploy-gcs-all verify ## Complete deployment of all apps (wallet to GCS)
497508

498509
# Quick deployments (assumes wallet and apps deployed)
499-
counter-quick: build-demo-counter deploy-gcs-counter verify ## Quick counter frontend update (no blockchain)
500-
fungible-quick: build-demo-fungible deploy-gcs-fungible verify ## Quick fungible frontend update (no blockchain)
501-
quick-deploy: build-demos-all deploy-gcs-all verify ## Quick frontend update all demos (no blockchain)
510+
counter-quick: fetch-env-counter build-demo-counter deploy-gcs-counter verify ## Quick counter frontend update (no blockchain)
511+
fungible-quick: fetch-env-fungible build-demo-fungible deploy-gcs-fungible verify ## Quick fungible frontend update (no blockchain)
512+
quick-deploy: fetch-env-all build-demos-all deploy-gcs-all verify ## Quick frontend update all demos (no blockchain)
502513

503514
# ===== Build Linera Binary =====
504515
build-linera: ## Build the linera binary (required first)

0 commit comments

Comments
 (0)