From 3a8397b9b0adc50c66a99d069b9d6ba095c8891e Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 3 Apr 2025 14:12:34 +0200 Subject: [PATCH 1/7] feat(cli): setup postgres17 for local development --- internal/db/dump/dump.go | 2 +- pkg/config/config.go | 5 ++++- pkg/config/constants.go | 1 + pkg/config/templates/Dockerfile | 1 + tools/selfhost/main.go | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index 5336e624a9..8ee344ecb5 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -173,7 +173,7 @@ func dump(ctx context.Context, config pgconn.Config, script string, env []string return utils.DockerRunOnceWithConfig( ctx, container.Config{ - Image: cliConfig.Images.Pg15, + Image: cliConfig.Images.Pg17, Env: allEnvs, Cmd: []string{"bash", "-c", script, "--"}, }, diff --git a/pkg/config/config.go b/pkg/config/config.go index 92fb5ba080..9a06276f98 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -600,6 +600,9 @@ func (c *config) Load(path string, fsys fs.FS) error { if strings.HasPrefix(string(version), "15.") && semver.Compare(string(version[3:]), "1.0.55") >= 0 { c.Db.Image = replaceImageTag(Images.Pg15, string(version)) } + if strings.HasPrefix(string(version), "17.") && semver.Compare(string(version[3:]), "1.0.55") >= 0 { + c.Db.Image = replaceImageTag(Images.Pg17, string(version)) + } } if c.Db.MajorVersion > 14 { if version, err := fs.ReadFile(fsys, builder.RestVersionPath); err == nil && len(version) > 0 { @@ -729,7 +732,7 @@ func (c *config) Validate(fsys fs.FS) error { c.Db.Image = pg13 case 14: c.Db.Image = pg14 - case 15: + case 15, 17: if len(c.Experimental.OrioleDBVersion) > 0 { c.Db.Image = "supabase/postgres:orioledb-" + c.Experimental.OrioleDBVersion if err := assertEnvLoaded(c.Experimental.S3Host); err != nil { diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 6cd352d684..ef5b50f8c0 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -16,6 +16,7 @@ const ( type images struct { Pg15 string `mapstructure:"pg15"` + Pg17 string `mapstructure:"pg17"` // Append to Services when adding new dependencies below Kong string `mapstructure:"kong"` Inbucket string `mapstructure:"mailpit"` diff --git a/pkg/config/templates/Dockerfile b/pkg/config/templates/Dockerfile index 13257acdc8..9efff20172 100644 --- a/pkg/config/templates/Dockerfile +++ b/pkg/config/templates/Dockerfile @@ -1,5 +1,6 @@ # Exposed for updates by .github/dependabot.yml FROM supabase/postgres:15.8.1.060 AS pg15 +FROM supabase/postgres:17.4.1.004 AS pg17 # Append to ServiceImages when adding new dependencies below FROM library/kong:2.8.1 AS kong FROM axllent/mailpit:v1.22.3 AS mailpit diff --git a/tools/selfhost/main.go b/tools/selfhost/main.go index 8eb19befc2..5e2d870433 100644 --- a/tools/selfhost/main.go +++ b/tools/selfhost/main.go @@ -61,7 +61,7 @@ func updateSelfHosted(ctx context.Context, branch string) error { } func getStableVersions() map[string]string { - images := append(config.Images.Services(), config.Images.Pg15) + images := append(config.Images.Services(), config.Images.Pg17) result := make(map[string]string, len(images)) for _, img := range images { parts := strings.Split(img, ":") From 8afc410306ac701d56c6cea23b1660b96f826809 Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 3 Apr 2025 14:44:52 +0200 Subject: [PATCH 2/7] chore: use v17 by default --- internal/utils/config.go | 2 +- pkg/config/config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index 06d42d4439..afaf8ec091 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -130,7 +130,7 @@ func InitConfig(params InitParams, fsys afero.Fs) error { c := config.NewConfig() c.ProjectId = params.ProjectId if params.UseOrioleDB { - c.Experimental.OrioleDBVersion = "15.1.0.150" + c.Experimental.OrioleDBVersion = c.Db.MajorVersion > 15 ? "17.0.1.57" : "15.1.0.150" } // Create config file if err := MkdirIfNotExistFS(fsys, SupabaseDirPath); err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index 9a06276f98..fa7d13d1f3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -333,7 +333,7 @@ func NewConfig(editors ...ConfigEditor) config { KongImage: Images.Kong, }, Db: db{ - Image: Images.Pg15, + Image: Images.Pg17, Password: "postgres", RootKey: Secret{ Value: "d4dc5b6d4a1d6a10b2c1e76112c994d65db7cec380572cc1839624d4be3fa275", From f236fd37517ca0e0c923f5d486857207c4042a06 Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 3 Apr 2025 14:46:20 +0200 Subject: [PATCH 3/7] chore: nitpick --- internal/utils/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index afaf8ec091..3f313fe42d 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -130,7 +130,11 @@ func InitConfig(params InitParams, fsys afero.Fs) error { c := config.NewConfig() c.ProjectId = params.ProjectId if params.UseOrioleDB { - c.Experimental.OrioleDBVersion = c.Db.MajorVersion > 15 ? "17.0.1.57" : "15.1.0.150" + if c.Db.MajorVersion > 15 { + c.Experimental.OrioleDBVersion = "17.0.1.57" + } else { + c.Experimental.OrioleDBVersion = "15.1.0.150" + } } // Create config file if err := MkdirIfNotExistFS(fsys, SupabaseDirPath); err != nil { From 22ee42561396d6a4483a68d9ab9eb21fa360d8ac Mon Sep 17 00:00:00 2001 From: avallete Date: Mon, 7 Apr 2025 11:02:06 +0200 Subject: [PATCH 4/7] chore: apply pr comments --- internal/utils/config.go | 6 +----- pkg/config/config.go | 11 +++++------ pkg/config/constants.go | 4 ++-- pkg/config/templates/Dockerfile | 3 +-- tools/selfhost/main.go | 2 +- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index 3f313fe42d..06d42d4439 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -130,11 +130,7 @@ func InitConfig(params InitParams, fsys afero.Fs) error { c := config.NewConfig() c.ProjectId = params.ProjectId if params.UseOrioleDB { - if c.Db.MajorVersion > 15 { - c.Experimental.OrioleDBVersion = "17.0.1.57" - } else { - c.Experimental.OrioleDBVersion = "15.1.0.150" - } + c.Experimental.OrioleDBVersion = "15.1.0.150" } // Create config file if err := MkdirIfNotExistFS(fsys, SupabaseDirPath); err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index fa7d13d1f3..fc1da6ab3c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -333,7 +333,7 @@ func NewConfig(editors ...ConfigEditor) config { KongImage: Images.Kong, }, Db: db{ - Image: Images.Pg17, + Image: Images.Pg, Password: "postgres", RootKey: Secret{ Value: "d4dc5b6d4a1d6a10b2c1e76112c994d65db7cec380572cc1839624d4be3fa275", @@ -598,10 +598,7 @@ func (c *config) Load(path string, fsys fs.FS) error { // Update image versions if version, err := fs.ReadFile(fsys, builder.PostgresVersionPath); err == nil { if strings.HasPrefix(string(version), "15.") && semver.Compare(string(version[3:]), "1.0.55") >= 0 { - c.Db.Image = replaceImageTag(Images.Pg15, string(version)) - } - if strings.HasPrefix(string(version), "17.") && semver.Compare(string(version[3:]), "1.0.55") >= 0 { - c.Db.Image = replaceImageTag(Images.Pg17, string(version)) + c.Db.Image = replaceImageTag(pg15, string(version)) } } if c.Db.MajorVersion > 14 { @@ -732,7 +729,7 @@ func (c *config) Validate(fsys fs.FS) error { c.Db.Image = pg13 case 14: c.Db.Image = pg14 - case 15, 17: + case 15: if len(c.Experimental.OrioleDBVersion) > 0 { c.Db.Image = "supabase/postgres:orioledb-" + c.Experimental.OrioleDBVersion if err := assertEnvLoaded(c.Experimental.S3Host); err != nil { @@ -748,6 +745,8 @@ func (c *config) Validate(fsys fs.FS) error { return err } } + case 17: + c.Db.Image = Images.Pg default: return errors.Errorf("Failed reading config: Invalid %s: %v.", "db.major_version", c.Db.MajorVersion) } diff --git a/pkg/config/constants.go b/pkg/config/constants.go index ef5b50f8c0..db1378b82c 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -11,12 +11,12 @@ import ( const ( pg13 = "supabase/postgres:13.3.0" pg14 = "supabase/postgres:14.1.0.89" + pg15 = "supabase/postgres:15.8.1.069" deno2 = "supabase/edge-runtime:v1.68.0-develop.12" ) type images struct { - Pg15 string `mapstructure:"pg15"` - Pg17 string `mapstructure:"pg17"` + Pg string `mapstructure:"pg"` // Append to Services when adding new dependencies below Kong string `mapstructure:"kong"` Inbucket string `mapstructure:"mailpit"` diff --git a/pkg/config/templates/Dockerfile b/pkg/config/templates/Dockerfile index 9efff20172..c4e8c8358a 100644 --- a/pkg/config/templates/Dockerfile +++ b/pkg/config/templates/Dockerfile @@ -1,6 +1,5 @@ # Exposed for updates by .github/dependabot.yml -FROM supabase/postgres:15.8.1.060 AS pg15 -FROM supabase/postgres:17.4.1.004 AS pg17 +FROM supabase/postgres:17.4.1.004 AS pg # Append to ServiceImages when adding new dependencies below FROM library/kong:2.8.1 AS kong FROM axllent/mailpit:v1.22.3 AS mailpit diff --git a/tools/selfhost/main.go b/tools/selfhost/main.go index 5e2d870433..be7886ae91 100644 --- a/tools/selfhost/main.go +++ b/tools/selfhost/main.go @@ -61,7 +61,7 @@ func updateSelfHosted(ctx context.Context, branch string) error { } func getStableVersions() map[string]string { - images := append(config.Images.Services(), config.Images.Pg17) + images := append(config.Images.Services(), config.Images.Pg) result := make(map[string]string, len(images)) for _, img := range images { parts := strings.Split(img, ":") From da791122749dd969b0ea78455f087131766cf483 Mon Sep 17 00:00:00 2001 From: avallete Date: Mon, 7 Apr 2025 11:03:35 +0200 Subject: [PATCH 5/7] chore: fix lint --- internal/db/dump/dump.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index 8ee344ecb5..2485ae9f89 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -173,7 +173,7 @@ func dump(ctx context.Context, config pgconn.Config, script string, env []string return utils.DockerRunOnceWithConfig( ctx, container.Config{ - Image: cliConfig.Images.Pg17, + Image: cliConfig.Images.Pg, Env: allEnvs, Cmd: []string{"bash", "-c", script, "--"}, }, From c7ab2d20976b8872a37607e139bfb86200b6104c Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 7 Apr 2025 23:59:40 +0800 Subject: [PATCH 6/7] chore: set default image based on major version --- pkg/config/config.go | 26 ++++++++++++++++---------- pkg/config/templates/Dockerfile | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index fc1da6ab3c..5471ca4e49 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -596,12 +596,22 @@ func (c *config) Load(path string, fsys fs.FS) error { c.Api.ExternalUrl = apiUrl.String() } // Update image versions - if version, err := fs.ReadFile(fsys, builder.PostgresVersionPath); err == nil { - if strings.HasPrefix(string(version), "15.") && semver.Compare(string(version[3:]), "1.0.55") >= 0 { - c.Db.Image = replaceImageTag(pg15, string(version)) - } + switch c.Db.MajorVersion { + case 13: + c.Db.Image = pg15 + case 14: + c.Db.Image = pg14 + case 15: + c.Db.Image = pg15 } if c.Db.MajorVersion > 14 { + if version, err := fs.ReadFile(fsys, builder.PostgresVersionPath); err == nil { + // Only replace image if postgres version is above 15.1.0.55 + if strings.HasPrefix(string(version), fmt.Sprintf("%d.", c.Db.MajorVersion)) && + (c.Db.MajorVersion != 15 || semver.Compare(string(version[3:]), "1.0.55") >= 0) { + c.Db.Image = replaceImageTag(pg15, string(version)) + } + } if version, err := fs.ReadFile(fsys, builder.RestVersionPath); err == nil && len(version) > 0 { c.Api.Image = replaceImageTag(Images.Postgrest, string(version)) } @@ -725,10 +735,8 @@ func (c *config) Validate(fsys fs.FS) error { return errors.New("Missing required field in config: db.major_version") case 12: return errors.New("Postgres version 12.x is unsupported. To use the CLI, either start a new project or follow project migration steps here: https://supabase.com/docs/guides/database#migrating-between-projects.") - case 13: - c.Db.Image = pg13 - case 14: - c.Db.Image = pg14 + case 13, 14, 17: + // TODO: support oriole db 17 eventually case 15: if len(c.Experimental.OrioleDBVersion) > 0 { c.Db.Image = "supabase/postgres:orioledb-" + c.Experimental.OrioleDBVersion @@ -745,8 +753,6 @@ func (c *config) Validate(fsys fs.FS) error { return err } } - case 17: - c.Db.Image = Images.Pg default: return errors.Errorf("Failed reading config: Invalid %s: %v.", "db.major_version", c.Db.MajorVersion) } diff --git a/pkg/config/templates/Dockerfile b/pkg/config/templates/Dockerfile index c4e8c8358a..2fc7930b07 100644 --- a/pkg/config/templates/Dockerfile +++ b/pkg/config/templates/Dockerfile @@ -1,5 +1,5 @@ # Exposed for updates by .github/dependabot.yml -FROM supabase/postgres:17.4.1.004 AS pg +FROM supabase/postgres:17.4.1.012 AS pg # Append to ServiceImages when adding new dependencies below FROM library/kong:2.8.1 AS kong FROM axllent/mailpit:v1.22.3 AS mailpit From 4b467e1d564abf6319023bcec33f914167a36902 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 8 Apr 2025 16:24:41 +0800 Subject: [PATCH 7/7] chore: use current db image for dump --- internal/db/dump/dump.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index 2485ae9f89..6c668f5bd7 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -14,7 +14,6 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" - cliConfig "github.com/supabase/cli/pkg/config" ) var ( @@ -173,7 +172,7 @@ func dump(ctx context.Context, config pgconn.Config, script string, env []string return utils.DockerRunOnceWithConfig( ctx, container.Config{ - Image: cliConfig.Images.Pg, + Image: utils.Config.Db.Image, Env: allEnvs, Cmd: []string{"bash", "-c", script, "--"}, },