diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 967ecff089..74610ccfdc 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -81,8 +81,11 @@ func StartDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...f hostConfig := WithSyslogConfig(container.HostConfig{ PortBindings: nat.PortMap{"5432/tcp": []nat.PortBinding{{HostPort: hostPort}}}, RestartPolicy: container.RestartPolicy{Name: "always"}, - Binds: []string{utils.DbId + ":/var/lib/postgresql/data"}, - ExtraHosts: []string{"host.docker.internal:host-gateway"}, + Binds: []string{ + utils.DbId + ":/var/lib/postgresql/data", + utils.ConfigId + ":/etc/postgresql-custom", + }, + ExtraHosts: []string{"host.docker.internal:host-gateway"}, }) if utils.Config.Db.MajorVersion <= 14 { config.Entrypoint = nil diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 49e52055da..d0bd0367e8 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -86,6 +86,7 @@ func TestStartDatabase(t *testing.T) { utils.DbImage = utils.Pg15Image utils.Config.Db.MajorVersion = 15 utils.DbId = "supabase_db_test" + utils.ConfigId = "supabase_config_test" utils.Config.Db.Port = 5432 // Setup in-memory fs fsys := afero.NewMemMapFs() diff --git a/internal/stop/stop.go b/internal/stop/stop.go index b97c9c6958..01905739f6 100644 --- a/internal/stop/stop.go +++ b/internal/stop/stop.go @@ -52,10 +52,12 @@ func stop(ctx context.Context, backup bool) error { // Remove named volumes if backup { fmt.Fprintln(os.Stderr, "Postgres database saved to volume:", utils.DbId) + fmt.Fprintln(os.Stderr, "Postgres config saved to volume:", utils.ConfigId) fmt.Fprintln(os.Stderr, "Storage directory saved to volume:", utils.StorageId) + fmt.Fprintln(os.Stderr, "Functions cache saved to volume:", utils.DenoRelayId) } else { // TODO: label named volumes to use VolumesPrune for branch support - volumes := []string{utils.DbId, utils.StorageId} + volumes := []string{utils.ConfigId, utils.DbId, utils.StorageId, utils.DenoRelayId} utils.WaitAll(volumes, func(name string) { if err := utils.Docker.VolumeRemove(ctx, name, true); err != nil { fmt.Fprintln(os.Stderr, "failed to remove volume:", name, err) diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index 3c65f026ac..1ad1e828f9 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -100,7 +100,9 @@ func TestStopServices(t *testing.T) { t.Run("removes data volumes", func(t *testing.T) { utils.DbId = "test-db" + utils.ConfigId = "test-config" utils.StorageId = "test-storage" + utils.DenoRelayId = "test-functions" // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) defer gock.OffAll() @@ -112,12 +114,18 @@ func TestStopServices(t *testing.T) { Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). JSON(types.ContainersPruneReport{}) + gock.New(utils.Docker.DaemonHost()). + Delete("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.ConfigId). + Reply(http.StatusOK) gock.New(utils.Docker.DaemonHost()). Delete("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.DbId). Reply(http.StatusOK) gock.New(utils.Docker.DaemonHost()). Delete("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.StorageId). Reply(http.StatusNotFound) + gock.New(utils.Docker.DaemonHost()). + Delete("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.DenoRelayId). + Reply(http.StatusNotFound) gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/networks/prune"). Reply(http.StatusOK). diff --git a/internal/utils/config.go b/internal/utils/config.go index 8be6892b3f..f52d26b3ab 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -21,6 +21,7 @@ var ( DbImage string NetId string DbId string + ConfigId string KongId string GotrueId string InbucketId string @@ -206,6 +207,7 @@ func LoadConfigFS(fsys afero.Fs) error { } else { NetId = "supabase_network_" + Config.ProjectId DbId = "supabase_db_" + Config.ProjectId + ConfigId = "supabase_config_" + Config.ProjectId KongId = "supabase_kong_" + Config.ProjectId GotrueId = "supabase_auth_" + Config.ProjectId InbucketId = "supabase_inbucket_" + Config.ProjectId