Skip to content
Open
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/google/go-github/v62 v62.0.0
github.com/google/go-querystring v1.2.0
github.com/google/jsonschema-go v0.4.2
github.com/google/uuid v1.6.0
github.com/h2non/gock v1.2.0
github.com/jackc/pgconn v1.14.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJ
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
Expand Down
23 changes: 17 additions & 6 deletions internal/functions/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ func parseEnvFile(envFilePath string, fsys afero.Fs) ([]string, error) {
return env, err
}

type dockerFunction struct {
VerifyJWT bool `json:"verifyJWT"`
EntrypointPath string `json:"entrypointPath,omitempty"`
ImportMapPath string `json:"importMapPath,omitempty"`
StaticFiles []string `json:"staticFiles,omitempty"`
}

func PopulatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) ([]string, string, error) {
slugs, err := deploy.GetFunctionSlugs(fsys)
if err != nil {
Expand All @@ -251,25 +258,29 @@ func PopulatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs
return nil, "", err
}
binds := []string{}
enabledFunctions := map[string]dockerFunction{}
for slug, fc := range functionsConfig {
if !fc.Enabled {
fmt.Fprintln(os.Stderr, "Skipped serving Function:", slug)
delete(functionsConfig, slug)
continue
}
modules, err := deploy.GetBindMounts(cwd, utils.FunctionsDir, "", fc.Entrypoint, fc.ImportMap, fsys)
if err != nil {
return nil, "", err
}
binds = append(binds, modules...)
fc.ImportMap = utils.ToDockerPath(fc.ImportMap)
fc.Entrypoint = utils.ToDockerPath(fc.Entrypoint)
functionsConfig[slug] = fc
enabled := dockerFunction{
VerifyJWT: fc.VerifyJWT,
EntrypointPath: utils.ToDockerPath(fc.Entrypoint),
ImportMapPath: utils.ToDockerPath(fc.ImportMap),
StaticFiles: make([]string, len(fc.StaticFiles)),
}
for i, val := range fc.StaticFiles {
fc.StaticFiles[i] = utils.ToDockerPath(val)
enabled.StaticFiles[i] = utils.ToDockerPath(val)
}
enabledFunctions[slug] = enabled
}
functionsConfigBytes, err := json.Marshal(functionsConfig)
functionsConfigBytes, err := json.Marshal(enabledFunctions)
if err != nil {
return nil, "", errors.Errorf("failed to marshal config json: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions internal/functions/serve/templates/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const GENERIC_FUNCTION_SERVE_MESSAGE = `Serving functions on http://127.0.0.1:${
interface FunctionConfig {
entrypointPath: string;
importMapPath: string;
staticFiles: string[];
verifyJWT: boolean;
}

Expand Down
5 changes: 5 additions & 0 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,10 @@ EOF
}

// Mount snippets directory for Studio to access
studioConfig, err := json.Marshal(utils.Config)
if err != nil {
return errors.Errorf("failed to marshal config: %w", err)
}
hostSnippetsPath := filepath.Join(workdir, utils.SnippetsDir)
containerSnippetsPath := utils.ToDockerPath(hostSnippetsPath)
binds = append(binds, fmt.Sprintf("%s:%s:rw", hostSnippetsPath, containerSnippetsPath))
Expand All @@ -1171,6 +1175,7 @@ EOF
fmt.Sprintf("NEXT_ANALYTICS_BACKEND_PROVIDER=%v", utils.Config.Analytics.Backend),
"EDGE_FUNCTIONS_MANAGEMENT_FOLDER=" + utils.ToDockerPath(filepath.Join(workdir, utils.FunctionsDir)),
"SNIPPETS_MANAGEMENT_FOLDER=" + containerSnippetsPath,
"SUPABASE_CONFIG=" + string(studioConfig),
// Ref: https://github.com/vercel/next.js/issues/51684#issuecomment-1612834913
"HOSTNAME=0.0.0.0",
},
Expand Down
28 changes: 14 additions & 14 deletions pkg/config/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import (

type (
api struct {
Enabled bool `toml:"enabled"`
Schemas []string `toml:"schemas"`
ExtraSearchPath []string `toml:"extra_search_path"`
MaxRows uint `toml:"max_rows"`
Enabled bool `toml:"enabled" json:"enabled"`
Schemas []string `toml:"schemas" json:"schemas"`
ExtraSearchPath []string `toml:"extra_search_path" json:"extra_search_path"`
MaxRows uint `toml:"max_rows" json:"max_rows"`
// Local only config
Image string `toml:"-"`
KongImage string `toml:"-"`
Port uint16 `toml:"port"`
Tls tlsKong `toml:"tls"`
Image string `toml:"-" json:"-"`
KongImage string `toml:"-" json:"-"`
Port uint16 `toml:"port" json:"port"`
Tls tlsKong `toml:"tls" json:"tls"`
// TODO: replace [auth|studio].api_url
ExternalUrl string `toml:"external_url"`
ExternalUrl string `toml:"external_url" json:"external_url"`
}

tlsKong struct {
Enabled bool `toml:"enabled"`
CertPath string `toml:"cert_path"`
CertContent []byte `toml:"-"`
KeyPath string `toml:"key_path"`
KeyContent []byte `toml:"-"`
Enabled bool `toml:"enabled" json:"enabled"`
CertPath string `toml:"cert_path" json:"cert_path"`
CertContent []byte `toml:"-" json:"-"`
KeyPath string `toml:"key_path" json:"key_path"`
KeyContent []byte `toml:"-" json:"-"`
}
)

Expand Down
Loading
Loading