# Build the existing Auth version with only the SMTP MIME change. Fail closed if
# upstream changes the integration point; no auth policies or templates changed.
FROM golang:1.27.0-alpine3.23 AS multipart-build
RUN apk add --no-cache git make
WORKDIR /src
RUN git init && git remote add origin https://github.com/supabase/auth.git && git fetch --depth=1 origin 4eee58f296d9698a1c2c0ae14d7a0b379c7622d3 && git checkout --detach FETCH_HEAD
COPY multipart.go multipart_test.go internal/mailer/mailmeclient/
RUN test "$(grep -c 'mail.SetBody("text/html", body)' internal/mailer/mailmeclient/mailmeclient.go)" = 1 && sed -i 's/mail.SetBody("text\/html", body)/if err := setAlternativeBodies(mail, body); err != nil { return err }/' internal/mailer/mailmeclient/mailmeclient.go
RUN gofmt -w internal/mailer/mailmeclient/*.go && go test ./internal/mailer/mailmeclient ./internal/mailer/templatemailer
RUN CGO_ENABLED=0 go build -buildvcs=false -ldflags "-X github.com/supabase/auth/internal/utilities.Version=v2.197.0-iisa-multipart" -o /src/auth .
FROM supabase/gotrue:v2.197.0
COPY --from=multipart-build /src/auth /usr/local/bin/auth
ENV GOTRUE_API_HOST=0.0.0.0 GOTRUE_API_PORT=9999 GOTRUE_DB_DRIVER=postgres GOTRUE_JWT_ADMIN_ROLES=service_role GOTRUE_JWT_AUD=authenticated GOTRUE_JWT_DEFAULT_GROUP_NAME=authenticated GOTRUE_JWT_EXP=3600 GOTRUE_EXTERNAL_EMAIL_ENABLED=true GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED=false GOTRUE_EXTERNAL_PHONE_ENABLED=false GOTRUE_MAILER_AUTOCONFIRM=false
