From b1b312d5e9a9802c147dedbd7923263cf186e618 Mon Sep 17 00:00:00 2001 From: Carlos Vera Date: Mon, 7 Sep 2026 10:01:16 +0200 Subject: [PATCH] feat(supabase): make storage S3 backend configurable via env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The template ships the S3 backend settings as commented-out literals, so switching storage to S3 means editing the compose file by hand. That does not survive on platforms like EasyPanel, where the service is sourced from git and the file is rewritten on every deploy. Expose them as environment variables instead, keeping 'file' as the default so existing deployments are unaffected. docker-compose.s3.yml stays as-is: it wires up a local MinIO with a fixed endpoint, which does not cover an external S3-compatible service. Also adds TUS_ALLOW_S3_TAGS: Cloudflare R2 does not implement x-amz-tagging, and resumable (TUS) uploads fail with HTTP 500 unless it is set to "false". Autor: Carlos Vera --- “Todo lo puedo en Cristo que me fortalece.” fil 4:13 --- supabase/code/.env.example | 13 +++++++++++++ supabase/code/docker-compose.yml | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/supabase/code/.env.example b/supabase/code/.env.example index 0b20ea2b5..52bd0d824 100644 --- a/supabase/code/.env.example +++ b/supabase/code/.env.example @@ -274,6 +274,19 @@ ENABLE_PHONE_AUTOCONFIRM=true # S3 bucket when using S3 backend, directory name when using 'file' GLOBAL_S3_BUCKET=stub +# Storage backend: 'file' (local disk, default) or 's3' (any S3-compatible +# service). The four settings below are only read when STORAGE_BACKEND=s3. +STORAGE_BACKEND=file +GLOBAL_S3_ENDPOINT= +GLOBAL_S3_PROTOCOL=https +GLOBAL_S3_FORCE_PATH_STYLE=true +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= + +# Cloudflare R2 does not implement x-amz-tagging: set this to "false" there, +# or resumable (TUS) uploads fail with HTTP 500. +TUS_ALLOW_S3_TAGS=true + # Used for S3 protocol endpoint configuration REGION=stub diff --git a/supabase/code/docker-compose.yml b/supabase/code/docker-compose.yml index 3ee2d3a95..132a0270b 100644 --- a/supabase/code/docker-compose.yml +++ b/supabase/code/docker-compose.yml @@ -367,15 +367,19 @@ services: STORAGE_PUBLIC_URL: ${SUPABASE_PUBLIC_URL} REQUEST_ALLOW_X_FORWARDED_PATH: "true" FILE_SIZE_LIMIT: 52428800 - STORAGE_BACKEND: file + STORAGE_BACKEND: ${STORAGE_BACKEND:-file} # S3 bucket when using S3 backend, directory name when using 'file' GLOBAL_S3_BUCKET: ${GLOBAL_S3_BUCKET} - # S3 Backend configuration - #GLOBAL_S3_ENDPOINT: https://your-s3-endpoint - #GLOBAL_S3_PROTOCOL: https - #GLOBAL_S3_FORCE_PATH_STYLE: "true" - #AWS_ACCESS_KEY_ID: your-access-key-id - #AWS_SECRET_ACCESS_KEY: your-secret-access-key + # S3 backend configuration. Only read when STORAGE_BACKEND=s3, so these + # stay inert on the default 'file' backend. + GLOBAL_S3_ENDPOINT: ${GLOBAL_S3_ENDPOINT} + GLOBAL_S3_PROTOCOL: ${GLOBAL_S3_PROTOCOL:-https} + GLOBAL_S3_FORCE_PATH_STYLE: ${GLOBAL_S3_FORCE_PATH_STYLE:-true} + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} + # Cloudflare R2 does not implement x-amz-tagging: set this to "false" + # there, or resumable (TUS) uploads fail with HTTP 500. + TUS_ALLOW_S3_TAGS: ${TUS_ALLOW_S3_TAGS:-true} FILE_STORAGE_BACKEND_PATH: /var/lib/storage TENANT_ID: ${STORAGE_TENANT_ID} # TODO: https://github.com/supabase/storage-api/issues/55 @@ -458,7 +462,7 @@ services: # Comment out everything below this point if you are using an external Postgres database db: # To upgrade an existing Postgres 15 database in place, see utils/upgrade-pg17.sh. - image: supabase/postgres:17.6.1.136 + image: supabase/postgres:17.6.1.150 restart: unless-stopped volumes: - ./volumes/db/realtime.sql:/docker-entrypoint-initdb.d/migrations/99-realtime.sql:Z