feat: optimize gotrue compile size

This commit is contained in:
Fu Zi Xiang 2023-11-24 19:13:33 +08:00
parent 51fbca057e
commit 04b2d79025
No known key found for this signature in database
5 changed files with 22 additions and 8 deletions

View File

@ -92,6 +92,5 @@ services:
# Prometheus Metrics
- GOTRUE_METRICS_ENABLED=true
- GOTRUE_METRICS_EXPORTER=prometheus
- GOTRUE_EXTERNAL_SAML_ENABLED=true
ports:
- 9998:9999

View File

@ -136,7 +136,6 @@ services:
# Prometheus Metrics
- GOTRUE_METRICS_ENABLED=true
- GOTRUE_METRICS_EXPORTER=prometheus
- GOTRUE_EXTERNAL_SAML_ENABLED=true
ports:
- 9998:9999

View File

@ -1,12 +1,10 @@
FROM golang as base
WORKDIR /go/src/supabase
RUN git clone https://github.com/supabase/gotrue.git
RUN git clone https://github.com/supabase/gotrue.git --depth 1 --branch v2.117.0
WORKDIR /go/src/supabase/gotrue
RUN git checkout e67a10c1 && \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
go build -o /gotrue .
COPY docker/gotrue.patch .
RUN git apply gotrue.patch
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /gotrue .
FROM scratch
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
@ -15,5 +13,6 @@ COPY --from=base /etc/passwd /etc/passwd
COPY --from=base /etc/group /etc/group
COPY --from=base /gotrue .
COPY --from=base /go/src/supabase/gotrue/migrations ./migrations
CMD ["./gotrue"]

15
docker/gotrue.patch Normal file
View File

@ -0,0 +1,15 @@
# This patch is done because there is no way to enable SSO/SAML at the moment
diff --git a/internal/api/api.go b/internal/api/api.go
index d9016fd0..924ce018 100644
--- a/internal/api/api.go
+++ b/internal/api/api.go
@@ -175,7 +175,7 @@ func NewAPIWithVersion(ctx context.Context, globalConfig *conf.GlobalConfigurati
})
r.Route("/sso", func(r *router) {
- r.Use(api.requireSAMLEnabled)
+ // r.Use(api.requireSAMLEnabled)
r.With(api.limitHandler(
// Allow requests at the specified rate per 5 minutes.
tollbooth.NewLimiter(api.config.RateLimitSso/(60*5), &limiter.ExpirableOptions{

View File

@ -1,3 +1,5 @@
-- This will be run before appflowy-cloud or gotrue does its migration
-- Add migration script here
-- Create the anon and authenticated roles if they don't exist
CREATE OR REPLACE FUNCTION create_roles(roles text []) RETURNS void LANGUAGE plpgsql AS $$