Skip to content
Draft
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: 4 additions & 3 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func validateExcludedContainers(excludedContainers []string) {
// Validate excluded containers
validContainers := start.ExcludableContainers()
var invalidContainers []string

Expand All @@ -25,7 +24,7 @@ func validateExcludedContainers(excludedContainers []string) {
}

if len(invalidContainers) > 0 {
// Sort the names list so it's easier to visually spot the one you looking for
// Sort the names list so it's easier to visually spot the one you're looking for
sort.Strings(validContainers)
warning := fmt.Sprintf("%s The following container names are not valid to exclude: %s\nValid containers to exclude are: %s\n",
utils.Yellow("WARNING:"),
Expand All @@ -40,14 +39,15 @@ var (
excludedContainers []string
ignoreHealthCheck bool
preview bool
small bool

startCmd = &cobra.Command{
GroupID: groupLocalDev,
Use: "start",
Short: "Start containers for Supabase local development",
RunE: func(cmd *cobra.Command, args []string) error {
validateExcludedContainers(excludedContainers)
return start.Run(cmd.Context(), afero.NewOsFs(), excludedContainers, ignoreHealthCheck)
return start.Run(cmd.Context(), afero.NewOsFs(), excludedContainers, ignoreHealthCheck, small)
},
}
)
Expand All @@ -58,6 +58,7 @@ func init() {
flags.StringSliceVarP(&excludedContainers, "exclude", "x", []string{}, "Names of containers to not start. ["+names+"]")
flags.BoolVar(&ignoreHealthCheck, "ignore-health-check", false, "Ignore unhealthy services and exit 0")
flags.BoolVar(&preview, "preview", false, "Connect to feature preview branch")
flags.BoolVar(&small, "small", false, "Use "+start.SmallImageName+" image")
cobra.CheckErr(flags.MarkHidden("preview"))
rootCmd.AddCommand(startCmd)
}
37 changes: 36 additions & 1 deletion internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,47 @@ import (
"github.com/supabase/cli/pkg/config"
)

func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error {
const (
SmallImageName = "supabase/postgres:minimal"
graphqlPublicSchema = "graphql_public"
)

// configureSmallMode configures the system for minimal resource usage by:
// - Using a smaller PostgreSQL image (minimal)
// - Disabling non-essential services (keeps only kong, postgrest, and auth)
// - Removing graphql_public schema from API schemas
func configureSmallMode() {
utils.Config.Db.Image = SmallImageName

// Disable all services except kong, postgrest, and auth
// This ensures they won't be pulled or started regardless of config.toml settings
utils.Config.Realtime.Enabled = false
utils.Config.Storage.Enabled = false
utils.Config.Inbucket.Enabled = false
utils.Config.Studio.Enabled = false
utils.Config.EdgeRuntime.Enabled = false
utils.Config.Analytics.Enabled = false
utils.Config.Db.Pooler.Enabled = false

// Remove graphql_public schema from API schemas when using --small
filteredSchemas := make([]string, 0, len(utils.Config.Api.Schemas))
for _, schema := range utils.Config.Api.Schemas {
if schema != graphqlPublicSchema {
filteredSchemas = append(filteredSchemas, schema)
}
}
utils.Config.Api.Schemas = filteredSchemas
}

func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool, useSmallImage bool) error {
// Sanity checks.
{
if err := flags.LoadConfig(fsys); err != nil {
return err
}
if useSmallImage {
configureSmallMode()
}
if err := utils.AssertSupabaseDbIsRunning(); err == nil {
fmt.Fprintln(os.Stderr, utils.Aqua("supabase start")+" is already running.")
names := status.CustomName{}
Expand Down
4 changes: 4 additions & 0 deletions internal/utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ func GetRegistryImageUrl(imageName string) string {
if registry == "docker.io" {
return imageName
}
// Skip registry transformation for minimal images (pulled locally from Docker Hub)
if strings.Contains(imageName, "minimal") {
return imageName
}
// Configure mirror registry
parts := strings.Split(imageName, "/")
imageName = parts[len(parts)-1]
Expand Down
Loading