From 22fd2b177678885c79084a95b9b021a674ef2510 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 17 May 2025 14:45:03 +0800 Subject: [PATCH] . --- Dockerfile | 37 +++++++++++++++++++++++++++++- supabase/gotrue/wrapper.sh | 18 ++++++++++++--- supabase/postgres/supervisord.conf | 22 ++++++------------ 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6a110b6..ac49f06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,29 @@ # syntax=docker/dockerfile:1.6 + +#============================================ gotrue build====================================================== +FROM golang:1.22.3-alpine3.20 as authbuild +ENV GO111MODULE=on +ENV CGO_ENABLED=0 +ENV GOOS=linux + +RUN apk add --no-cache make git + +WORKDIR /go/src/github.com/supabase/auth + +# Pulling dependencies +COPY ./Makefile ./go.* ./ +RUN make deps + +# Building stuff +COPY . /go/src/github.com/supabase/auth + +# Make sure you change the RELEASE_VERSION value before publishing an image. +RUN RELEASE_VERSION=unspecified make build + + + + + #============================================ postgres ==================================================== ARG postgresql_major=15 ARG postgresql_release=${postgresql_major}.1 @@ -241,4 +266,14 @@ RUN apt-get update -y \ COPY postgrest_v12.2.8/postgrest /usr/bin/postgrest RUN chmod +x /usr/bin/postgrest -#=========================================== goture ============================================== \ No newline at end of file +#=========================================== goture include============================================== +RUN useradd -m -u 1000 supabase + +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* +COPY --from=authbuild /go/src/github.com/supabase/auth/auth /usr/local/bin/auth +COPY --from=authbuild /go/src/github.com/supabase/auth/migrations /usr/local/etc/auth/migrations/ +RUN ln -s /usr/local/bin/auth /usr/local/bin/gotrue + +ENV GOTRUE_DB_MIGRATIONS_PATH=/usr/local/etc/auth/migrations + +#========================================== storage-api ==================================================== \ No newline at end of file diff --git a/supabase/gotrue/wrapper.sh b/supabase/gotrue/wrapper.sh index 2e6a4c6..f1a4078 100644 --- a/supabase/gotrue/wrapper.sh +++ b/supabase/gotrue/wrapper.sh @@ -1,9 +1,21 @@ #!/bin/bash -set -e +set -euo pipefail +echo "[gotrue] Waiting for PostgREST on localhost:3000..." + +# 等待 postgrest 启动就绪 until curl -s http://localhost:3000/ >/dev/null 2>&1; do - echo "Waiting for postgrest..." + echo "[gotrue] Waiting..." sleep 1 done -exec /app/gotrue ... +echo "[gotrue] PostgREST is ready. Starting GoTrue..." + +# 必要环境变量(监听默认 127.0.0.1:9999 即可) +export GOTRUE_SITE_URL="http://localhost:3000" +export GOTRUE_JWT_SECRET="super-secret-jwt-token-with-at-least-32-characters-long" +export GOTRUE_DB_DRIVER="postgres" +export DATABASE_URL="postgres://supabase_admin:postgres@localhost:5432/postgres" + +# 启动 GoTrue(路径视你 build 的二进制实际位置) +exec /usr/local/bin/auth diff --git a/supabase/postgres/supervisord.conf b/supabase/postgres/supervisord.conf index e8e4a07..16cb18d 100644 --- a/supabase/postgres/supervisord.conf +++ b/supabase/postgres/supervisord.conf @@ -32,6 +32,13 @@ stderr_logfile=/var/log/postgrest.err.log stdout_logfile=/var/log/postgrest.out.log environment=PGRST_DB_URI="postgres://postgres:postgres@localhost:5432/postgres",PGRST_DB_ANON_ROLE="anon",PGRST_DB_SCHEMA="public",PGRST_JWT_SECRET="super-secret-jwt-token-with-at-least-32-characters-long",PGRST_SERVER_PORT="3000",PGRST_LOG_LEVEL="debug" +[program:auth] +command=/bin/bash /supabase/gotrue/wrapper.sh +autorestart=true +stderr_logfile=/var/log/auth.err.log +stdout_logfile=/var/log/auth.out.log + + # [program:kong] # command=/supabase/kong/docker-entrypoint.sh kong docker-start # autorestart=true @@ -51,21 +58,6 @@ environment=PGRST_DB_URI="postgres://postgres:postgres@localhost:5432/postgres", # KONG_ADMIN_ERROR_LOG="/dev/stderr", # KONG_PREFIX="/usr/local/kong" -# [program:auth] -# command=/usr/local/bin/auth -c=/etc/gotrue/.env -# autorestart=true -# stderr_logfile=/var/log/auth.err.log -# stdout_logfile=/var/log/auth.out.log -# environment= -# GOTRUE_SITE_URL="http://localhost:3000", -# GOTRUE_JWT_SECRET="", -# GOTRUE_DB_MIGRATIONS_PATH="/usr/local/etc/auth/migrations", -# GOTRUE_DB_DRIVER="postgres", -# DATABASE_URL="postgres://supabase_auth_admin:root@127.0.0.1:5432/postgres", -# GOTRUE_API_HOST="0.0.0.0", -# API_EXTERNAL_URL="http://localhost:9999", -# PORT="9999" - # [program:storage-api] # command=/usr/bin/node /supabase/storage-api/dist/start/server.js