Add password setup script for Supabase roles
Build and Push Docker Image / build (push) Successful in 1m51s
Details
Build and Push Docker Image / build (push) Successful in 1m51s
Details
The Supabase postgres image's internal migrate.sh requires supabase_admin to have a password matching POSTGRES_PASSWORD. Added zz-set-passwords.sh to run after init.sql and set passwords dynamically using the environment variable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0e93961bb9
commit
cfbf7639c2
|
|
@ -32,6 +32,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||||
|
- ./zz-set-passwords.sh:/docker-entrypoint-initdb.d/zz-set-passwords.sh:ro
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ GRANT authenticated TO authenticator;
|
||||||
GRANT service_role TO authenticator;
|
GRANT service_role TO authenticator;
|
||||||
GRANT supabase_admin TO postgres;
|
GRANT supabase_admin TO postgres;
|
||||||
|
|
||||||
-- Note: Passwords for supabase_admin and authenticator are set by the Supabase image
|
-- Note: Passwords for supabase_admin, authenticator, and other roles are set by
|
||||||
-- based on POSTGRES_PASSWORD environment variable. Don't override them here.
|
-- zz-set-passwords.sh which runs after this script and uses POSTGRES_PASSWORD.
|
||||||
|
|
||||||
-- Create schemas
|
-- Create schemas
|
||||||
CREATE SCHEMA IF NOT EXISTS auth AUTHORIZATION supabase_auth_admin;
|
CREATE SCHEMA IF NOT EXISTS auth AUTHORIZATION supabase_auth_admin;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Monaco USA Portal - Set Role Passwords
|
||||||
|
# This script runs AFTER init.sql to set passwords for Supabase roles
|
||||||
|
# using the POSTGRES_PASSWORD environment variable.
|
||||||
|
#
|
||||||
|
# The Supabase postgres image's internal migrate.sh expects supabase_admin
|
||||||
|
# to have a password matching POSTGRES_PASSWORD.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Setting passwords for Supabase roles..."
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||||
|
-- Set supabase_admin password (required by Supabase internal scripts)
|
||||||
|
ALTER ROLE supabase_admin WITH PASSWORD '${POSTGRES_PASSWORD}';
|
||||||
|
|
||||||
|
-- Set authenticator password (used by PostgREST)
|
||||||
|
ALTER ROLE authenticator WITH PASSWORD '${POSTGRES_PASSWORD}';
|
||||||
|
|
||||||
|
-- Set supabase_auth_admin password (used by GoTrue)
|
||||||
|
ALTER ROLE supabase_auth_admin WITH LOGIN PASSWORD '${POSTGRES_PASSWORD}';
|
||||||
|
|
||||||
|
-- Set supabase_storage_admin password (used by Storage API)
|
||||||
|
ALTER ROLE supabase_storage_admin WITH LOGIN PASSWORD '${POSTGRES_PASSWORD}';
|
||||||
|
EOSQL
|
||||||
|
|
||||||
|
echo "Supabase role passwords configured successfully."
|
||||||
Loading…
Reference in New Issue