diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index 5336e624a9..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.Pg15, + Image: utils.Config.Db.Image, Env: allEnvs, Cmd: []string{"bash", "-c", script, "--"}, }, diff --git a/pkg/config/config.go b/pkg/config/config.go index 92fb5ba080..5471ca4e49 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.Pg, Password: "postgres", RootKey: Secret{ Value: "d4dc5b6d4a1d6a10b2c1e76112c994d65db7cec380572cc1839624d4be3fa275", @@ -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(Images.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 diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 1cb39832dc..28f61b208d 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -11,11 +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.13" ) type images struct { - Pg15 string `mapstructure:"pg15"` + 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 13257acdc8..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:15.8.1.060 AS pg15 +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 diff --git a/tools/selfhost/main.go b/tools/selfhost/main.go index 8eb19befc2..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.Pg15) + images := append(config.Images.Services(), config.Images.Pg) result := make(map[string]string, len(images)) for _, img := range images { parts := strings.Split(img, ":")