supabase / supabase

The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
https://supabase.com
Apache License 2.0
73.55k stars 7.1k forks source link

[Self Hosting]: docker container `supabase-analytics` is failed to start #22304

Closed leiless closed 7 months ago

leiless commented 7 months ago

Bug report

Describe the bug

Run self-hosted supabase with podman 3.4.4, and the supabase-analytics is failed to start.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

# Get the code
git clone --depth 1 https://github.com/supabase/supabase

# Go to the docker folder
cd supabase/docker

# Copy the fake env vars
cp .env.example .env

# Pull the latest images
docker compose pull

# Start the services (in detached mode)
docker compose up -d

Podman logs

$ docker ps -a
CONTAINER ID  IMAGE                                       COMMAND               CREATED        STATUS                               PORTS                                           NAMES
701a2864db08  docker.io/darthsim/imgproxy:v3.8.0          imgproxy              7 minutes ago  Up 7 minutes ago (healthy)                                                           supabase-imgproxy
42cdf3da242b  docker.io/timberio/vector:0.28.1-alpine     --config etc/vect...  7 minutes ago  Up 7 minutes ago (healthy)                                                           supabase-vector
b6acdf5480eb  docker.io/supabase/postgres:15.1.0.147      postgres -c confi...  7 minutes ago  Up 7 minutes ago (healthy)           0.0.0.0:5432->5432/tcp                          supabase-db
8a0d774229db  docker.io/supabase/logflare:1.4.0           sh run.sh             7 minutes ago  Exited (1) 7 minutes ago (starting)  0.0.0.0:4000->4000/tcp                          supabase-analytics
429ccc72e74b  docker.io/supabase/studio:20240301-0942bfe  node apps/studio/...  7 minutes ago  Up 7 minutes ago (unhealthy)                                                         supabase-studio
1f1a06ecc79a  docker.io/library/kong:2.8.1                                      7 minutes ago  Up 7 minutes ago (healthy)           0.0.0.0:8000->8000/tcp, 0.0.0.0:8443->8443/tcp  supabase-kong
cb130beb8005  docker.io/supabase/gotrue:v2.143.0          auth                  7 minutes ago  Up 7 minutes ago (healthy)                                                           supabase-auth
45143f382b57  docker.io/postgrest/postgrest:v12.0.1       postgrest             7 minutes ago  Up 7 minutes ago                                                                     supabase-rest
b67ce8100768  docker.io/supabase/realtime:v2.25.66        sh -c /app/bin/mi...  7 minutes ago  Up 7 minutes ago (unhealthy)                                                         realtime-dev.supabase-realtime
702841692cc5  docker.io/supabase/postgres-meta:v0.80.0    node dist/server/...  7 minutes ago  Up 7 minutes ago                                                                     supabase-meta
c90b0a6d9a4a  docker.io/supabase/edge-runtime:v1.38.0     start --main-serv...  7 minutes ago  Up 7 minutes ago                                                                     supabase-edge-functions
3adb85b105df  docker.io/supabase/storage-api:v0.46.4      node dist/server....  7 minutes ago  Up 7 minutes ago (healthy)                                                           supabase-storage

$ docker logs supabase-analytics
LOGFLARE_NODE_HOST is: 127.0.0.1
ERROR! Config provider Config.Reader failed with:
** (File.Error) could not read file "gcloud.json": no such file or directory
    (elixir 1.14.4) lib/file.ex:358: File.read!/1
    /opt/app/rel/logflare/releases/1.4.0/runtime.exs:204: (file)
    (elixir 1.14.4) src/elixir.erl:309: anonymous fn/4 in :elixir.eval_external_handler/1
    (stdlib 4.3.1) erl_eval.erl:748: :erl_eval.do_apply/7
    (stdlib 4.3.1) erl_eval.erl:961: :erl_eval.expr_list/7
    (stdlib 4.3.1) erl_eval.erl:290: :erl_eval.expr/6
    (stdlib 4.3.1) erl_eval.erl:282: :erl_eval.expr/6
    (stdlib 4.3.1) erl_eval.erl:961: :erl_eval.expr_list/7

{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.File.Error',action=><<"read file">>,path=><<"gcloud.json">>,reason=>enoent},[{'Elixir.File','read!',1,[{file,"lib/file.ex"},{line,358}]},{elixir_eval,'__FILE__',1,[{file,"/opt/app/rel/logflare/releases/1.4.0/runtime.exs"},{line,204}]},{elixir,'-eval_external_handler/1-fun-2-',4,[{file,"src/elixir.erl"},{line,309}]},{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,748}]},{erl_eval,expr_list,7,[{file,"erl_eval.erl"},{line,961}]},{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,290}]},{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,282}]},{erl_eval,expr_list,7,[{file,"erl_eval.erl"},{line,961}]}]}}
init terminating in do_boot ({,[{Elixir.File,read!,1,[{_},{_}]},{elixir_eval,__FILE__,1,[{_},{_}]},{elixir,-eval_external_handler/1-fun-2-,4,[{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,expr_list,7,[{_},{_}]},{erl_eval,expr,6,[{_},{_}]},{erl_eval,expr,6,[{_},{_}]},{erl_eval,expr_list,7,[{_},{_}]}]})

Crash dump is being written to: erl_crash.dump...done
ERROR! Config provider Config.Reader failed with:
{"init terminating in do_b** (File.Error) could not read file "gcloud.json": no such file or directory
    (elixir 1.14.4) lib/file.ex:358: File.read!/1
    /opt/app/rel/logflare/releases/1.4.0/runtime.exs:204: (file)
    (elixir 1.14.4) src/elixir.erl:309: anonymous fn/4 in :elixir.eval_external_handler/1
    (stdlib 4.3.1) erl_eval.erl:748: :erl_eval.do_apply/7
    (stdlib 4.3.1) erl_eval.erl:961: :erl_eval.expr_list/7
    (stdlib 4.3.1) erl_eval.erl:290: :erl_eval.expr/6
    (stdlib 4.3.1) erl_eval.erl:282: :erl_eval.expr/6
    (stdlib 4.3.1) erl_eval.erl:961: :erl_eval.expr_list/7

oot",{#{'__exception__'=>true,'__struct__'=>'Elixir.File.Error',action=><<"read file">>,path=><<"gcloud.json">>,reason=>enoent},[{'Elixir.File','read!',1,[{file,"lib/file.ex"},{line,358}]},{elixir_eval,'__FILE__',1,[{file,"/opt/app/rel/logflare/releases/1.4.0/runtime.exs"},{line,204}]},{elixir,'-eval_external_handler/1-fun-2-',4,[{file,"src/elixir.erl"},{line,309}]},{erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,748}]},{erl_eval,expr_list,7,[{file,"erl_eval.erl"},{line,961}]},{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,290}]},{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,282}]},{erl_eval,expr_list,7,[{file,"erl_eval.erl"},{line,961}]}]}}
init terminating in do_boot ({,[{Elixir.File,read!,1,[{_},{_}]},{elixir_eval,__FILE__,1,[{_},{_}]},{elixir,-eval_external_handler/1-fun-2-,4,[{_},{_}]},{erl_eval,do_apply,7,[{_},{_}]},{erl_eval,expr_list,7,[{_},{_}]},{erl_eval,expr,6,[{_},{_}]},{erl_eval,expr,6,[{_},{_}]},{erl_eval,expr_list,7,[{_},{_}]}]})

Crash dump is being written to: erl_crash.dump...done

Note the cause: (File.Error) could not read file "gcloud.json": no such file or directory

System information

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ podman version
Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.18.1
Built:        Thu Jan  1 08:00:00 1970
OS/Arch:      linux/amd64

$ podman-compose version
podman-compose version: 1.0.7
['podman', '--version', '']
using podman version: 3.4.4
podman-compose version 1.0.7
podman --version
podman version 3.4.4
exit code: 0
leiless commented 7 months ago

Might related: https://github.com/supabase/supabase/pull/13632

    # Uncomment to use Big Query backend for analytics
    # volumes:
    #   - type: bind
    #     source: ${PWD}/gcloud.json
    #     target: /opt/app/rel/logflare/bin/gcloud.json
    #     read_only: true

      # Uncomment to use Big Query backend for analytics
      # GOOGLE_PROJECT_ID: ${GOOGLE_PROJECT_ID}
      # GOOGLE_PROJECT_NUMBER: ${GOOGLE_PROJECT_NUMBER}

https://github.com/Logflare/logflare/blob/v1.4.0/config/runtime.exs#L192-L211

encima commented 7 months ago

Hi @leiless

Thanks for opening! I cannot reproduce this on MacOS (orbstack) or Linux (podman). Can you make sure that any volumes are removed and that the lines you mention are commented? Potentially podman has an issue with the comments in the file but, as I cannot repro, I am not sure if this is the case

image
encima commented 7 months ago

Closing as this has not had a follow up but, if the issue still occurs, let us know and we can reopen!

ASmallPotato commented 6 months ago

I have encountered the same issue, and I found the underlying problem and a workaround.

I'm using the command podman-compose -f docker/docker-compose.yml up analytics (it is the same if I'm having the whole stack up); from the terminal output, I see it was running the below command (truncated for brevity)

podman create --name=supabase-analytics ........ -e LOGFLARE_SINGLE_TENANT=True .... supabase/logflare:1.4.0

the important bits being it was running the command using "True" as the LOGFLARE_SINGLE_TENANT parameter value even though in the yml file it is lowercase true. But in logflare, it was actually being compared as a string, and since "True" != "true", the condition fall through and tries to use google cloud stuff instead of postgres

The "workaround" is directly use the string "true" instead of the implicit boolean true for those specific variables, i.e. in docker-compose.yml, under "environment" for "analytics":

      LOGFLARE_SINGLE_TENANT: "true"
FYI, my podman-compose -v:
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.9.2
podman-compose version 1.0.6
podman --version
podman version 4.9.2
exit code: 0