beachPartyBalloons/docker-compose.yml
chris 5b9524e1d9 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>
2026-08-19 11:27:49 -04:00

150 lines
5.6 KiB
YAML

services:
# ── Nginx reverse proxy ───────────────────────────────────────────────────────
nginx:
image: nginx:alpine
container_name: bpb-nginx
ports:
- "3000:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/well-known:/etc/nginx/well-known:ro
depends_on:
main-site:
condition: service_started
estore:
condition: service_healthy
restart: always
# ── Main website ─────────────────────────────────────────────────────────────
main-site:
build: ./main-site
container_name: bpb-main
expose:
- "3050"
environment:
NODE_ENV: production
ADMIN_PASSWORD: ${MAIN_ADMIN_PASSWORD}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_SECURE: ${SMTP_SECURE:-false}
SMTP_USER: ${SMTP_USER}
SMTP_PASS: ${SMTP_PASS}
CONTACT_TO: ${CONTACT_TO}
NTFY_URL: ${NTFY_URL:-}
ALTCHA_HMAC_KEY: ${ALTCHA_HMAC_KEY}
volumes:
- ./main-site/update.json:/usr/src/app/update.json
restart: always
depends_on:
- gallery-backend
# ── Photo gallery backend ─────────────────────────────────────────────────────
gallery-backend:
build: ./main-site/photo-gallery-app/backend
container_name: bpb-gallery
ports:
- "5002:5000"
environment:
MONGO_URI: mongodb://mongodb:27017/photogallery
WATERMARK_URL: http://watermarker:8000/watermark
ADMIN_PASSWORD: ${MAIN_ADMIN_PASSWORD}
volumes:
- ./main-site/photo-gallery-app/backend/uploads:/usr/src/app/uploads
depends_on:
- mongodb
- watermarker
restart: always
# ── Watermarker ───────────────────────────────────────────────────────────────
watermarker:
build: ./main-site/photo-gallery-app/watermarker
container_name: bpb-watermarker
restart: always
# ── MongoDB ───────────────────────────────────────────────────────────────────
mongodb:
image: mongo:latest
container_name: bpb-mongodb
volumes:
- ./mongodb_data:/data/db
restart: always
# ── eStore (Next.js / Square) ─────────────────────────────────────────────────
# NEXT_PUBLIC_* vars are baked into the JS bundle at build time.
# They are resolved from the root .env file (same dir as this compose file).
estore:
build:
context: ./estore
args:
NEXT_PUBLIC_SQUARE_APP_ID: ${NEXT_PUBLIC_SQUARE_APP_ID}
NEXT_PUBLIC_SQUARE_LOCATION_ID: ${NEXT_PUBLIC_SQUARE_LOCATION_ID}
NEXT_PUBLIC_SQUARE_ENVIRONMENT: ${NEXT_PUBLIC_SQUARE_ENVIRONMENT}
NEXT_PUBLIC_SITE_URL: ${NEXT_PUBLIC_SITE_URL}
container_name: bpb-estore
expose:
- "3000"
env_file: ./estore/.env
environment:
OSRM_URL: ${OSRM_URL} # injected from root .env; overrides estore/.env
volumes:
- ./estore/data:/app/data
restart: unless-stopped
depends_on:
- osrm
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/shop/api/catalog').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
interval: 30s
timeout: 10s
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) ─────────────────────────────────────────
# Downloads the PBF map file into the shared volume if not already present.
osrm-download:
build:
context: ./osrm
dockerfile: Dockerfile.download
container_name: bpb-osrm-download
volumes:
- ./osrm/data:/data
environment:
OSRM_REGION: connecticut-latest
restart: "no"
# ── OSRM (routing engine) ─────────────────────────────────────────────────────
osrm:
build: ./osrm
container_name: bpb-osrm
expose:
- "5000"
volumes:
- ./osrm/data:/data
environment:
OSRM_REGION: connecticut-latest
OSRM_PROFILE: /opt/car.lua
depends_on:
osrm-download:
condition: service_completed_successfully
restart: unless-stopped