Skip to content

Commit

Permalink
feat: add pg-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Aug 13, 2021
1 parent 9defab3 commit a5c7ae3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,8 @@ ALTER EVENT TRIGGER issue_pg_cron_access OWNER TO postgres;
"projectId": "%[1]s",
"ports": {
"api": 8000,
"db": 5432
"db": 5432,
"pgMeta": 3000
},
"dbVersion": "120007",
"excludeSchemas": ["extensions"]
Expand Down
27 changes: 27 additions & 0 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ func Start() error {
}
io.Copy(os.Stdout, out)
}
if _, _, err := utils.Docker.ImageInspectWithRaw(ctx, "docker.io/"+utils.PgMetaImage); err != nil {
out, err := utils.Docker.ImagePull(ctx, "docker.io/"+utils.PgMetaImage, types.ImagePullOptions{})
if err != nil {
return err
}
io.Copy(os.Stdout, out)
}
}

fmt.Println("Done pulling images.")
Expand Down Expand Up @@ -513,6 +520,26 @@ EOSQL

fmt.Println("Started.")

// Start pg-meta.

if err := utils.DockerRun(
ctx,
utils.PgMetaId,
&container.Config{
Image: utils.PgMetaImage,
Env: []string{
"PG_META_PORT=8080",
"PG_META_DB_HOST=" + utils.DbId,
},
},
&container.HostConfig{
PortBindings: nat.PortMap{"8080/tcp": []nat.PortBinding{{HostPort: utils.PgMetaPort}}},
NetworkMode: container.NetworkMode(utils.NetId),
},
); err != nil {
return err
}

// switch db on switch branch

for {
Expand Down
7 changes: 6 additions & 1 deletion internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ GRANT supabase_admin TO authenticator GRANTED BY postgres;
RealtimeImage = "supabase/realtime:v0.15.0"
PostgrestImage = "postgrest/postgrest:v7.0.1"
DifferImage = "supabase/pgadmin-schema-diff:cli-0.0.2"
PgMetaImage = "supabase/postgres-meta:v0.24.1"
// Latest supabase/postgres image *on hosted platform*.
LatestDbImage = "supabase/postgres:0.14.0"
LatestDbImage = "supabase/postgres:0.14.0"
)

var (
Expand All @@ -138,6 +139,7 @@ var (
}()
ApiPort string
DbPort string
PgMetaPort string
DbImage string
ProjectId string
NetId string
Expand All @@ -148,6 +150,7 @@ var (
RealtimeId string
RestId string
DifferId string
PgMetaId string
)

func GetCurrentTimestamp() string {
Expand Down Expand Up @@ -186,6 +189,7 @@ func LoadConfig() {

ApiPort = fmt.Sprint(viper.GetUint("ports.api"))
DbPort = fmt.Sprint(viper.GetUint("ports.db"))
PgMetaPort = fmt.Sprint(viper.GetUint("ports.pgMeta"))
dbVersion := viper.GetString("dbVersion")
switch dbVersion {
case "120007":
Expand All @@ -203,6 +207,7 @@ func LoadConfig() {
RealtimeId = "supabase_realtime_" + ProjectId
RestId = "supabase_rest_" + ProjectId
DifferId = "supabase_differ_" + ProjectId
PgMetaId = "supabase_pg_meta_" + ProjectId
}

func AssertSupabaseStartIsRunning() {
Expand Down

0 comments on commit a5c7ae3

Please sign in to comment.