Initializing docker database

We use supabase, and really want to use the database in our CI env!

We already have exported the data from our dev environment to the preview_data.sql file and try to start the database with following docker-compose service entry:
  database:
    image: supabase/postgres:latest
    ports:
      - 5432:5432
    command: postgres -c config_file=/etc/postgresql/postgresql.conf 
    volumes:
      - ./data/preview_data.sql:/docker-entrypoint-initdb.d/preview_data.sql
    environment:
      POSTGRES_PASSWORD: postgres


it fails:

database_1  | [local] 2022-09-07 12:46:16.815 UTC [70] postgres@postgres ERROR:  role "supabase_admin" does not exist
database_1  | [local] 2022-09-07 12:46:16.815 UTC [70] postgres@postgres STATEMENT:  ALTER SCHEMA auth OWNER TO supabase_admin;
database_1  | psql:/docker-entrypoint-initdb.d/preview_data.sql:26: ERROR:  role "supabase_admin" does not exist
preview-infrastructure_database_1 exited with code 3


However, it seems like this role is being set up after files from the docker-entrypoint-initdb.d folder is being executed. When we use psql postgres://postgres:postgres@localhost -f ./data/preview_data.sql it works flawlessly!

Anyone with suggestions to getting the file in docker-entrypoint-initdb.d to work?
Was this page helpful?