Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions internal/db/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/db/start/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion internal/stop/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions internal/stop/stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
DbImage string
NetId string
DbId string
ConfigId string
KongId string
GotrueId string
InbucketId string
Expand Down Expand Up @@ -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
Expand Down