-
-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add inbucket to local setup (#78)
* Add inbucket * Add additional Gotrue configuration * chore: gofmt * make inbucket opt-in * hide inbucket url when not enabled * only bind inbucket port when enabled Co-authored-by: Bobbie Soedirgo <[email protected]>
- Loading branch information
Showing
3 changed files
with
111 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,9 @@ func Run() error { | |
if err := utils.AssertPortIsAvailable(utils.PgmetaPort); err != nil { | ||
return err | ||
} | ||
if err := utils.AssertPortIsAvailable(utils.InbucketPort); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
s := spinner.NewModel() | ||
|
@@ -154,9 +157,15 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | |
func (m model) View() string { | ||
// TODO: Unhardcode keys | ||
if m.started { | ||
maybeInbucket := "" | ||
if utils.InbucketPort != "" { | ||
maybeInbucket = ` | ||
Inbucket URL: http://localhost:` + utils.InbucketPort | ||
} | ||
|
||
return `Started local development setup. | ||
API URL: http://localhost:` + utils.ApiPort + ` | ||
DB URL: postgresql://postgres:postgres@localhost:` + utils.DbPort + `/postgres | ||
DB URL: postgresql://postgres:postgres@localhost:` + utils.DbPort + "/postgres" + maybeInbucket + ` | ||
anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiJ9.ZopqoUt20nEV9cklpv9e3yw3PVyZLmKs5qLD6nGL1SI | ||
service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIn0.M2d2z4SFn5C7HlJlaSLfrzuYim9nbY_XI40uWFN3hEE` | ||
} | ||
|
@@ -323,6 +332,19 @@ func run(p *tea.Program) error { | |
return err | ||
} | ||
} | ||
if _, _, err := utils.Docker.ImageInspectWithRaw(ctx, "docker.io/"+utils.InbucketImage); err != nil { | ||
out, err := utils.Docker.ImagePull( | ||
ctx, | ||
"docker.io/"+utils.InbucketImage, | ||
types.ImagePullOptions{}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if err := utils.ProcessPullOutput(out, p); err != nil { | ||
return err | ||
} | ||
} | ||
if _, _, err := utils.Docker.ImageInspectWithRaw(ctx, "docker.io/"+utils.RealtimeImage); err != nil { | ||
out, err := utils.Docker.ImagePull( | ||
ctx, | ||
|
@@ -689,35 +711,76 @@ EOSQL | |
|
||
// Start gotrue. | ||
|
||
if _, err := utils.DockerRun( | ||
ctx, | ||
utils.GotrueId, | ||
&container.Config{ | ||
Image: utils.GotrueImage, | ||
Env: []string{ | ||
"GOTRUE_API_HOST=0.0.0.0", | ||
"GOTRUE_API_PORT=9999", | ||
{ | ||
env := []string{ | ||
"API_EXTERNAL_URL=http://localhost:" + utils.ApiPort, | ||
|
||
"GOTRUE_API_HOST=0.0.0.0", | ||
"GOTRUE_API_PORT=9999", | ||
|
||
"GOTRUE_DB_DRIVER=postgres", | ||
"GOTRUE_DB_DATABASE_URL=postgres://supabase_auth_admin:postgres@" + utils.PgbouncerId + ":5432/postgres?sslmode=disable", | ||
|
||
"GOTRUE_DB_DRIVER=postgres", | ||
"GOTRUE_DB_DATABASE_URL=postgres://supabase_auth_admin:postgres@" + utils.PgbouncerId + ":5432/postgres?sslmode=disable", | ||
"GOTRUE_SITE_URL=http://localhost:3000", | ||
"GOTRUE_DISABLE_SIGNUP=false", | ||
|
||
"GOTRUE_SITE_URL=http://localhost:8000", | ||
"GOTRUE_DISABLE_SIGNUP=false", | ||
"GOTRUE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long", | ||
"GOTRUE_JWT_EXP=3600", | ||
"GOTRUE_JWT_DEFAULT_GROUP_NAME=authenticated", | ||
|
||
"GOTRUE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long", | ||
"GOTRUE_JWT_EXP=3600", | ||
"GOTRUE_JWT_DEFAULT_GROUP_NAME=authenticated", | ||
"GOTRUE_EXTERNAL_EMAIL_ENABLED=true", | ||
|
||
"GOTRUE_EXTERNAL_EMAIL_ENABLED=true", | ||
"GOTRUE_MAILER_AUTOCONFIRM=true", | ||
"GOTRUE_EXTERNAL_PHONE_ENABLED=true", | ||
"GOTRUE_SMS_AUTOCONFIRM=true", | ||
} | ||
|
||
"GOTRUE_EXTERNAL_PHONE_ENABLED=true", | ||
"GOTRUE_SMS_AUTOCONFIRM=true", | ||
if utils.InbucketPort == "" { | ||
env = append(env, "GOTRUE_MAILER_AUTOCONFIRM=true") | ||
} else { | ||
env = append(env, | ||
"GOTRUE_MAILER_AUTOCONFIRM=false", | ||
"GOTRUE_SMTP_HOST="+utils.InbucketId, | ||
"GOTRUE_SMTP_PORT=2500", | ||
"GOTRUE_SMTP_USER=GOTRUE_SMTP_USER", | ||
"GOTRUE_SMTP_PASS=GOTRUE_SMTP_PASS", | ||
"[email protected]", | ||
"GOTRUE_MAILER_URLPATHS_INVITE=/auth/v1/verify", | ||
"GOTRUE_MAILER_URLPATHS_CONFIRMATION=/auth/v1/verify", | ||
"GOTRUE_MAILER_URLPATHS_RECOVERY=/auth/v1/verify", | ||
"GOTRUE_MAILER_URLPATHS_EMAIL_CHANGE=/auth/v1/verify", | ||
) | ||
} | ||
|
||
if _, err := utils.DockerRun( | ||
ctx, | ||
utils.GotrueId, | ||
&container.Config{ | ||
Image: utils.GotrueImage, | ||
Env: env, | ||
}, | ||
}, | ||
&container.HostConfig{NetworkMode: container.NetworkMode(utils.NetId)}, | ||
); err != nil { | ||
return err | ||
&container.HostConfig{NetworkMode: container.NetworkMode(utils.NetId)}, | ||
); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// Start Inbucket. | ||
{ | ||
hostConfig := container.HostConfig{NetworkMode: container.NetworkMode(utils.NetId)} | ||
if utils.InbucketPort != "" { | ||
hostConfig.PortBindings = nat.PortMap{"9000/tcp": []nat.PortBinding{{HostPort: utils.InbucketPort}}} | ||
} | ||
|
||
if _, err := utils.DockerRun( | ||
ctx, | ||
utils.InbucketId, | ||
&container.Config{ | ||
Image: utils.InbucketImage, | ||
}, | ||
&hostConfig, | ||
); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// Start Realtime. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters