mirror of
https://github.com/readest/readest.git
synced 2026-11-29 19:02:28 +00:00
* fix(docker): apply db migrations on first boot and let the font CDN be overridden (#5550) A fresh self-hosted stack only ran volumes/db/init/schema.sql, so the incremental files under volumes/db/migrations never reached the database. Deployments came up without files.replica_id, the replicas table and the claim_inbox_item RPC, which broke uploads, replica sync and Send to Readest. Mount the migrations directory into the db container together with an apply-migrations.sh hook named so it sorts after the supabase image's own migrate.sh. It globs the mounted directory, so a new migration file needs no compose change, and it records what it applied in readest_meta.migrations so it can be re-run by hand after an upgrade. The reader also loaded its CJK webfont bundles from storage.readest.com, which only sends CORS headers for readest.com origins, so they were blocked on a custom domain. Read the base URL from runtime config via FONT_BASE_URL and keep the CDN as the default. Let SUPABASE_PUBLIC_URL and S3_PUBLIC_ENDPOINT be set directly instead of only being derived from HOST_IP, so the stack can be served from one HTTPS origin. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs(docker): add an example nginx config for a single HTTPS origin Keeps the template out of the README as a copyable file next to .env.example. Routes / to the client, /auth/v1 and /rest/v1 to kong, and the bucket prefix to minio with the Host header preserved so presigned signatures still verify. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
159 lines
5.5 KiB
YAML
159 lines
5.5 KiB
YAML
name: readest
|
|
|
|
services:
|
|
db:
|
|
container_name: supabase-db
|
|
image: supabase/postgres:15.8.1.085
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./volumes/db/roles.sql:/docker-entrypoint-initdb.d/init-scripts/99-roles.sql:Z
|
|
- ./volumes/db/jwt.sql:/docker-entrypoint-initdb.d/init-scripts/99-jwt.sql:Z
|
|
- ./volumes/db/init/schema.sql:/docker-entrypoint-initdb.d/init-scripts/100-schema.sql:Z
|
|
# Incremental migrations on top of the base schema above. The hook name
|
|
# sorts after the image's own migrate.sh, so it runs once the Supabase
|
|
# core schema and 100-schema.sql exist. It globs the mounted directory,
|
|
# so a new migration file needs no compose edit (#5550).
|
|
- ./volumes/db/migrations:/readest-migrations:Z
|
|
- ./volumes/db/apply-migrations.sh:/docker-entrypoint-initdb.d/zz-readest-migrations.sh:Z
|
|
- db-data:/var/lib/postgresql/data:Z
|
|
- db-config:/etc/postgresql-custom
|
|
environment:
|
|
POSTGRES_HOST: /var/run/postgresql
|
|
PGPORT: ${POSTGRES_PORT}
|
|
POSTGRES_PORT: ${POSTGRES_PORT}
|
|
PGPASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
PGDATABASE: ${POSTGRES_DB}
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
JWT_SECRET: ${JWT_SECRET}
|
|
JWT_EXP: ${JWT_EXPIRY}
|
|
command:
|
|
- postgres
|
|
- -c
|
|
- config_file=/etc/postgresql/postgresql.conf
|
|
- -c
|
|
- log_min_messages=fatal
|
|
|
|
kong:
|
|
container_name: supabase-kong
|
|
image: kong:2.8.1
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${KONG_HTTP_PORT}:8000/tcp"
|
|
volumes:
|
|
- ./volumes/api/kong.yml:/home/kong/temp.yml:ro,z
|
|
environment:
|
|
KONG_DATABASE: "off"
|
|
KONG_DECLARATIVE_CONFIG: /home/kong/kong.yml
|
|
KONG_DNS_ORDER: LAST,A,CNAME
|
|
KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth
|
|
SUPABASE_ANON_KEY: ${ANON_KEY}
|
|
SUPABASE_SERVICE_KEY: ${SERVICE_ROLE_KEY}
|
|
entrypoint: bash -c 'eval "echo \"$$(cat ~/temp.yml)\"" > ~/kong.yml && /docker-entrypoint.sh kong docker-start'
|
|
|
|
auth:
|
|
container_name: supabase-auth
|
|
image: supabase/gotrue:v2.185.0
|
|
restart: unless-stopped
|
|
environment:
|
|
GOTRUE_API_HOST: 0.0.0.0
|
|
GOTRUE_API_PORT: 9999
|
|
API_EXTERNAL_URL: ${API_EXTERNAL_URL}
|
|
GOTRUE_DB_DRIVER: postgres
|
|
GOTRUE_DB_DATABASE_URL: postgres://supabase_auth_admin:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/${POSTGRES_DB}
|
|
GOTRUE_SITE_URL: ${SITE_URL}
|
|
GOTRUE_URI_ALLOW_LIST: ${ADDITIONAL_REDIRECT_URLS}
|
|
GOTRUE_DISABLE_SIGNUP: ${DISABLE_SIGNUP}
|
|
GOTRUE_JWT_ADMIN_ROLES: service_role
|
|
GOTRUE_JWT_AUD: authenticated
|
|
GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated
|
|
GOTRUE_JWT_EXP: ${JWT_EXPIRY}
|
|
GOTRUE_JWT_SECRET: ${JWT_SECRET}
|
|
GOTRUE_EXTERNAL_EMAIL_ENABLED: ${ENABLE_EMAIL_SIGNUP}
|
|
GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED: ${ENABLE_ANONYMOUS_USERS}
|
|
GOTRUE_MAILER_AUTOCONFIRM: ${ENABLE_EMAIL_AUTOCONFIRM}
|
|
GOTRUE_SMTP_HOST: ${SMTP_HOST}
|
|
GOTRUE_SMTP_PORT: ${SMTP_PORT}
|
|
GOTRUE_SMTP_USER: ${SMTP_USER}
|
|
GOTRUE_SMTP_PASS: ${SMTP_PASS}
|
|
GOTRUE_SMTP_ADMIN_EMAIL: ${SMTP_ADMIN_EMAIL}
|
|
GOTRUE_SMTP_SENDER_NAME: ${SMTP_SENDER_NAME}
|
|
|
|
rest:
|
|
container_name: supabase-rest
|
|
image: postgrest/postgrest:v14.3
|
|
restart: unless-stopped
|
|
environment:
|
|
PGRST_DB_URI: postgres://authenticator:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/${POSTGRES_DB}
|
|
PGRST_DB_SCHEMAS: ${PGRST_DB_SCHEMAS}
|
|
PGRST_DB_ANON_ROLE: anon
|
|
PGRST_JWT_SECRET: ${JWT_SECRET}
|
|
PGRST_DB_USE_LEGACY_GUCS: "false"
|
|
PGRST_APP_SETTINGS_JWT_SECRET: ${JWT_SECRET}
|
|
PGRST_APP_SETTINGS_JWT_EXP: ${JWT_EXPIRY}
|
|
command: ["postgrest"]
|
|
|
|
minio:
|
|
container_name: readest-minio
|
|
image: minio/minio
|
|
restart: unless-stopped
|
|
ports:
|
|
- "9000:9000"
|
|
- "9001:9001"
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
|
command: server --console-address ":9001" /data
|
|
volumes:
|
|
- minio-data:/data:z
|
|
healthcheck:
|
|
test: ["CMD", "mc", "ready", "local"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
minio-setup:
|
|
image: minio/mc
|
|
depends_on:
|
|
minio:
|
|
condition: service_healthy
|
|
entrypoint: >
|
|
/bin/sh -c "
|
|
mc alias set myminio http://minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD} &&
|
|
mc mb --ignore-existing myminio/${S3_BUCKET_NAME}
|
|
"
|
|
|
|
client:
|
|
container_name: readest-client
|
|
image: ${READEST_IMAGE:-ghcr.io/readest/readest:latest}
|
|
pull_policy: missing
|
|
restart: unless-stopped
|
|
ports:
|
|
- "3000:3000"
|
|
environment:
|
|
SUPABASE_URL: http://kong:8000
|
|
# Browser-facing URLs. The HOST_IP defaults suit a plain IP/port
|
|
# deployment; behind an HTTPS reverse proxy, set them in .env to the
|
|
# single public origin (see README).
|
|
SUPABASE_PUBLIC_URL: ${SUPABASE_PUBLIC_URL:-http://${HOST_IP}:${KONG_HTTP_PORT:-8000}}
|
|
SUPABASE_ANON_KEY: ${ANON_KEY}
|
|
SUPABASE_ADMIN_KEY: ${SERVICE_ROLE_KEY}
|
|
API_BASE_URL: ${SITE_URL}
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_PUBLIC_ENDPOINT: ${S3_PUBLIC_ENDPOINT:-http://${HOST_IP}:9000}
|
|
S3_REGION: us-east-1
|
|
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
|
|
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER}
|
|
S3_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD}
|
|
OBJECT_STORAGE_TYPE: ${OBJECT_STORAGE_TYPE:-s3}
|
|
STORAGE_FIXED_QUOTA: ${STORAGE_FIXED_QUOTA:-1073741824}
|
|
TRANSLATION_FIXED_QUOTA: ${TRANSLATION_FIXED_QUOTA:-50000}
|
|
FONT_BASE_URL: ${FONT_BASE_URL:-}
|
|
depends_on:
|
|
- kong
|
|
- minio
|
|
|
|
volumes:
|
|
db-config:
|
|
db-data:
|
|
minio-data:
|