efa6b4a205
@Rekoo-PS confirmed the prior #521 fix landed on beta but reported the preview still shows the default "PicPeak" title — their brand is "arkan-studio". Root cause: that fix used Vite's build-time %VITE_DEFAULT_TITLE% substitution. Self-hosters running the pre-built ghcr.io/the-luap/picpeak/frontend image can't override at build time without rebuilding, so they were stuck with whatever the upstream build baked in. Pivot to runtime substitution: the frontend container now reads BRAND_TITLE / BRAND_DESCRIPTION env vars on startup and envsubsts them into index.html. Change the values in .env, restart the frontend service, done — no rebuild required. Mechanics: - frontend/index.html: tokens are now ${BRAND_TITLE} / ${BRAND_DESCRIPTION} (shell expansion syntax, passes through Vite unchanged into the built dist). - frontend/Dockerfile: install gettext (provides envsubst), snapshot /usr/share/nginx/html/index.html → index.html.tpl at build, install docker-entrypoint.sh, wire ENTRYPOINT to it. The .tpl is the immutable source — every container start re-renders index.html from .tpl, so restarts pick up new env values cleanly (no accidental "first-boot env stuck forever" trap). - frontend/docker-entrypoint.sh: applies defaults if env unset, runs envsubst (locked to BRAND_TITLE + BRAND_DESCRIPTION explicitly so /assets/*.js template literals aren't touched if anyone ever extends substitution to the bundle), execs nginx. - frontend/vite.config.ts: drop the htmlTitleDefaults plugin — no longer needed since substitution is fully runtime. - frontend/.env.example + .env.production.example: drop the VITE_DEFAULT_* docs (the vars no longer have effect). - docker-compose.yml + docker-compose.production.yml: pass BRAND_TITLE / BRAND_DESCRIPTION env into the frontend service with sensible defaults so unconfigured installs work unchanged. - .env.example: add BRAND_TITLE / BRAND_DESCRIPTION with comment pointing at the social-preview use case. Verified end-to-end against the built image: - BRAND_TITLE="Arkan Studio" BRAND_DESCRIPTION="Wedding photographs by Arkan Studio" → index.html serves <title>Arkan Studio</title> + og:title="Arkan Studio" + og:description correctly substituted. - .tpl preserves ${...} tokens so the next restart can re-substitute. - Bundle assets unaffected. - Defaults applied when env unset → <title>PicPeak</title>. Docs PR in picpeak-docs describes the two new env vars under "Social link preview fallback" in the environment-variables reference. Refs: #521
142 lines
4.5 KiB
YAML
142 lines
4.5 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: picpeak-postgres
|
|
userns_mode: "host"
|
|
environment:
|
|
POSTGRES_USER: ${DB_USER:-picpeak}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
POSTGRES_DB: ${DB_NAME:-picpeak}
|
|
volumes:
|
|
- postgres-data:/var/lib/postgresql/data
|
|
networks:
|
|
- picpeak-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
# `pg_isready -U <user>` without -d defaults to probing a database
|
|
# whose name matches the user — postgres then logs constant
|
|
# `FATAL: database "picpeak" does not exist` even though the
|
|
# actual DB is `picpeak_prod`. Pinning -d to DB_NAME makes the
|
|
# probe hit the real database and silences the log noise that
|
|
# made #484's reporter think the install was broken.
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-picpeak} -d ${DB_NAME:-picpeak}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: picpeak-redis
|
|
userns_mode: "host"
|
|
command: redis-server --requirepass ${REDIS_PASSWORD}
|
|
volumes:
|
|
- redis-data:/data
|
|
networks:
|
|
- picpeak-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
backend:
|
|
# Use pre-built image from GitHub Container Registry
|
|
# PICPEAK_CHANNEL: 'stable' (default), 'beta', or specific version like 'v2.3.0'
|
|
image: ghcr.io/the-luap/picpeak/backend:${PICPEAK_CHANNEL:-stable}
|
|
container_name: picpeak-backend
|
|
env_file: .env
|
|
environment:
|
|
- NODE_ENV=production
|
|
- DB_HOST=${DB_HOST:-postgres}
|
|
- REDIS_HOST=redis
|
|
- STORAGE_PATH=/app/storage
|
|
- PHOTOS_DIR=/app/storage/events
|
|
- PICPEAK_RELEASE_CHANNEL=${PICPEAK_CHANNEL:-stable}
|
|
volumes:
|
|
- ${APP_STORAGE}:/app/storage
|
|
- ${LOGS}:/app/logs
|
|
- ${APP_DATA}:/app/data
|
|
ports:
|
|
- "${BACKEND_PORT:-3001}:3000"
|
|
networks:
|
|
- picpeak-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
# Backend exposes /health on internal port 3000.
|
|
# The backend image only ships wget (Alpine base) — using curl
|
|
# here makes `docker ps` show the container as `unhealthy`
|
|
# indefinitely even when /health responds. Mirrors the wget-based
|
|
# HEALTHCHECK already declared in backend/Dockerfile so docker
|
|
# compose, plain `docker run`, and `docker ps` all agree.
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
frontend:
|
|
# Use pre-built image from GitHub Container Registry
|
|
# Uses same channel as backend for consistency
|
|
image: ghcr.io/the-luap/picpeak/frontend:${PICPEAK_CHANNEL:-stable}
|
|
container_name: picpeak-frontend
|
|
# Note: Pre-built frontend uses Nginx to proxy /api to backend:3001.
|
|
# Prefer keeping API base as '/api' in builds to avoid CORS.
|
|
environment:
|
|
# Substituted into index.html at container start (see frontend/
|
|
# docker-entrypoint.sh) so social link previews reaching the
|
|
# static SPA shell (WhatsApp Business API, Twilio, LinkPreview,
|
|
# etc. — see #521) show the configured brand instead of the
|
|
# generic "PicPeak" default. Defaults applied when unset; restart
|
|
# the frontend container after changing for the new title to
|
|
# take effect.
|
|
- BRAND_TITLE=${BRAND_TITLE:-PicPeak}
|
|
- BRAND_DESCRIPTION=${BRAND_DESCRIPTION:-Photo gallery shared with PicPeak.}
|
|
ports:
|
|
- "${FRONTEND_PORT:-3000}:80"
|
|
networks:
|
|
- picpeak-network
|
|
depends_on:
|
|
- backend
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# Optional: Nginx reverse proxy for production with SSL
|
|
# Uncomment and configure if you want built-in HTTPS support
|
|
# nginx:
|
|
# image: nginx:alpine
|
|
# container_name: picpeak-nginx
|
|
# ports:
|
|
# - "80:80"
|
|
# - "443:443"
|
|
# volumes:
|
|
# - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
# - ./nginx/ssl:/etc/nginx/ssl:ro
|
|
# - ./nginx/conf.d:/etc/nginx/conf.d:ro
|
|
# networks:
|
|
# - picpeak-network
|
|
# depends_on:
|
|
# - frontend
|
|
# - backend
|
|
# restart: unless-stopped
|
|
|
|
volumes:
|
|
postgres-data:
|
|
driver: local
|
|
redis-data:
|
|
driver: local
|
|
|
|
networks:
|
|
picpeak-network:
|
|
driver: bridge
|