Add scheduled Square catalog refresh via Docker sidecar
Catalog data only refreshed on first boot, admin button click, or checkout retry — nothing kept it fresh on a schedule despite the cache-refresh endpoint being built for cron use. A Next instrumentation hook was tried first but broke the build (middleware.ts forces instrumentation.ts into the same edge bundle, which can't resolve fs/path/crypto). Using a lightweight cron sidecar in the compose stack instead, so it ships with the deployment regardless of host. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
219256be55
commit
5b9524e1d9
@ -98,6 +98,27 @@ services:
|
|||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
|
# ── Scheduled Square catalog refresh ─────────────────────────────────────────
|
||||||
|
# Hits estore's cache-refresh endpoint on a timer so catalog/pricing edits made
|
||||||
|
# in Square show up without a redeploy or manual admin-panel refresh. Runs as
|
||||||
|
# part of the stack itself, so it works on any host this compose file is deployed to.
|
||||||
|
estore-cache-refresh:
|
||||||
|
image: alpine:3.20
|
||||||
|
container_name: bpb-estore-cache-refresh
|
||||||
|
env_file: ./estore/.env
|
||||||
|
depends_on:
|
||||||
|
estore:
|
||||||
|
condition: service_healthy
|
||||||
|
entrypoint: >
|
||||||
|
sh -c "
|
||||||
|
apk add --no-cache curl >/dev/null 2>&1;
|
||||||
|
while true; do
|
||||||
|
curl -sf -X POST http://estore:3000/shop/api/cache/refresh -H \"Authorization: Bearer $$CACHE_REFRESH_SECRET\" || echo 'cache refresh failed';
|
||||||
|
sleep 21600;
|
||||||
|
done
|
||||||
|
"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
# ── OSRM download (runs once, exits) ─────────────────────────────────────────
|
# ── OSRM download (runs once, exits) ─────────────────────────────────────────
|
||||||
# Downloads the PBF map file into the shared volume if not already present.
|
# Downloads the PBF map file into the shared volume if not already present.
|
||||||
osrm-download:
|
osrm-download:
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user