我正在尝试设置一个 GitHub Actions 工作流程,它将启动 supabase 数据库作为一个步骤,我最终想运行我在 Django 中编写的测试,但是当尝试启动 Supabase Postgres 容器时出现这些初始化错误。这是我当前的配置和错误:
Error message:
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/migrate.sh
[local] 2024-10-31 01:36:07.736 UTC [75] supabase_admin@test_db FATAL: password authentication failed for user "supabase_admin"
[local] 2024-10-31 01:36:07.736 UTC [75] supabase_admin@test_db DETAIL: Role "supabase_admin" does not exist.
Connection matched pg_hba.conf line 82: "local all supabase_admin scram-sha-256"
Error: Failed to initialize container supabase/postgres:15.6.1.133
Error: One or more containers failed to start.
当前 GitHub Actions 工作流程配置:
services:
postgres:
image: supabase/postgres:15.6.1.133
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ****
POSTGRES_DB: test_db
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_db
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
调查了您的问题,但无法查明其具体根本原因。显然,这是 SUPABASE 特有的东西。您可能想在他们的存储库上打开一个问题以获得对此的澄清。
但是,这对我有用:
name: supabase_services_container
on: workflow_dispatch
jobs:
ci:
runs-on: ubuntu-latest
services:
postgres:
image: supabase/postgres:15.6.1.133
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd=pg_isready
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Install postgresql-client (psql)
run: |
sudo apt update -y
sudo apt install -y postgresql-client
psql --version
- name: Check
run: |
psql "postgresql://postgres:postgres@localhost:5432" <<EOF
CREATE TABLE test (id INT);
INSERT INTO test (id) VALUES (123);
INSERT INTO test (id) VALUES (456);
INSERT INTO test (id) VALUES (789);
SELECT * FROM test;
EOF
输出: