This commit is contained in:
hailin 2025-05-17 14:45:03 +08:00
parent 58b5cf7862
commit 22fd2b1776
3 changed files with 58 additions and 19 deletions

View File

@ -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 ==============================================
#=========================================== 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 ====================================================

View File

@ -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

View File

@ -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