supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.02k stars 201 forks source link

Supabase cli unable to start containers on github actions #1737

Closed clayton-cc closed 5 months ago

clayton-cc commented 9 months ago

Describe the bug Running supabase start on github actions leads to auth error

To Reproduce Steps to reproduce the behavior:

  1. Create a github action
  2. Use supabase/setup-cli@v1, version: latest for supabase, ubuntu-latest for actions runner, actions/setup-node@v3 with node-version: 18
  3. Run supabase start
  4. See error

Expected behavior Supabase starts and is able to be interacted with

Screenshots image Desktop (please complete the following information):

Additional context

Cross-posting this from the setup-cli repo as I had originally posted there.. We have been using latest version of the CLI within github actions. On Friday tests were passing, this morning they aren't as we aren't able to get supabase up and running within our actions. I did some various version testing after finding an older version still works fine with the following results:

Version Starting
1.123.3
1.123.0
1.122.0
1.121.1
1.121.0
1.120.0
1.119.1
1.119.0
1.115.5

Happy to try any other debugging or changes to the action

sweatybridge commented 9 months ago

Could you share the output from running supabase services in your github action? Our CI test seems to be passing so there might be some project specific config that's causing it.

clayton-cc commented 9 months ago

image

Here is the output of supabase services. We are pinning to major_version = 14 for the [db] block of our config.toml

sweatybridge commented 9 months ago

Hmm I added pg14 to our test matrix and it still reported healthy. I went through the changes in 1.120.0 again and they seem unrelated to local password.

Could you check if there's any migrations altering the database password?

grep -ri supabase_admin supabase/migrations

Another thing you can try is to run supabase db start in your workflow instead. This launches just the database without other services. If this works, then you can try connecting via psql. For example,

steps:
  - run: supabase db start
  - run: psql -h localhost -U supabase_admin -p 54322 -c 'select 1'
    env:
      PGPASSWORD: postgres
clayton-cc commented 9 months ago

No hits for grep -r "supabase_admin" supabase/migrations

Doing a (ignore whitespace issue from copy/paste):

  run: |
          supabase services
          supabase db start
          psql -h localhost -U supabase_admin -d postgres -p 54322 -c 'select 1'
          supabase status
          docker ps
        env:
          PGPASSWORD: postgres

gives

 ?column? 
----------
        1
(1 row)

Stopped services: [supabase_kong_database-migrator supabase_auth_database-migrator supabase_inbucket_database-migrator realtime-dev.supabase_realtime_database-migrator supabase_rest_database-migrator supabase_storage_database-migrator storage_imgproxy_database-migrator supabase_pg_meta_database-migrator supabase_studio_database-migrator supabase_analytics_database-migrator]
supabase local development setup is running.

          DB URL: ***127.0.0.1:54322/postgres
CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS                    PORTS                                         NAMES
d349bba2e04c   ghcr.io/supabase/postgres:14.1.0.89   "docker-entrypoint.s…"   13 seconds ago   Up 12 seconds (healthy)   0.0.0.0:54322->5432/tcp, :::54322->5432/tcp   supabase_db_database-migrator

which seems to be working. If I follow that with supabase start it reports

supabase start is already running.
Run supabase status to show status of local Supabase containers

Doing a supabase stop and a following supabase start gives the same error as the original

sweatybridge commented 9 months ago

Thanks for these logs. I think we are making progress. Could you try isolating the realtime service since the error seems to be from there?

supabase start -x realtime

I've also made a new beta release with updated pg14 initial schema. I'm not sure if it fixes this specific issue but please give it a try. You can do that by setting the version of setup-cli to 1.123.6.

clayton-cc commented 9 months ago

out.txt

Here is the output of the following, I just appended it to the previous debugging commands. I called stop so we wouldn't get the supabase start is already running


        run: |
          supabase services
          supabase db start
          psql -h localhost -U supabase_admin -d postgres -p 54322 -c 'select 1'
          supabase status
          docker ps
          supabase stop
          supabase start -x realtime
        env:
          PGPASSWORD: postgres
sweatybridge commented 9 months ago

I still can't reproduce this error. Do you mind getting the logs from the following command?

        run: |
          supabase start -x realtime,storage-api,imgproxy,kong,inbucket,postgrest,pgadmin-schema-diff,migra,postgres-meta,studio,edge-runtime,logflare,vector,pgbouncer
sweatybridge commented 5 months ago

We have updated realtime in latest CLI release which changes the order which realtime migrations are run.

If this is still a problem, I think the best resolution is to upgrade your hosted project to PG15.

Hope it helps!