Skip to content

Commit

Permalink
fix: use http scheme for vector docker host
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Jul 23, 2024
1 parent 084d99b commit f5a667c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions internal/functions/deploy/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointDir, hostImpor
hostFuncDir += sep
}
dockerFuncDir := utils.ToDockerPath(hostFuncDir)
// TODO: bind ./supabase/functions:/home/deno/functions to hide PII?
binds := []string{
// Reuse deno cache directory, ie. DENO_DIR, between container restarts
// https://denolib.gitbook.io/guide/advanced/deno_dir-code-fetch-and-cache
Expand Down Expand Up @@ -128,6 +129,7 @@ func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointDir, hostImpor
binds = append(binds, hostEntrypointDir+":"+dockerEntrypointDir+":ro")
}
}
// Imports outside of ./supabase/functions will be bound by absolute path
if len(hostImportMapPath) > 0 {
if !filepath.IsAbs(hostImportMapPath) {
hostImportMapPath = filepath.Join(cwd, hostImportMapPath)
Expand Down
1 change: 1 addition & 0 deletions internal/functions/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs
}
binds = append(binds, modules...)
fc.ImportMap = utils.ToDockerPath(fc.ImportMap)
fc.Entrypoint = utils.ToDockerPath(fc.Entrypoint)
functionsConfig[slug] = fc
}
functionsConfigBytes, err := json.Marshal(functionsConfig)
Expand Down
9 changes: 7 additions & 2 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
_ "embed"
"fmt"
"net"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -282,8 +283,12 @@ EOF
// Special case for GitLab pipeline
host := utils.Docker.DaemonHost()
if parsed, err := client.ParseHostURL(host); err == nil && parsed.Scheme == "tcp" {
parsed.Host = "host.docker.internal"
env = append(env, "DOCKER_HOST="+parsed.String())
_, port, err := net.SplitHostPort(parsed.Host)
if err != nil {
return errors.Errorf("failed to split docker host port: %w", err)
}
// Ref: https://vector.dev/docs/reference/configuration/sources/docker_logs/#docker_host
env = append(env, "DOCKER_HOST=http://host.docker.internal:"+port)
} else if parsed, err := client.ParseHostURL(client.DefaultDockerHost); err == nil {
if host != client.DefaultDockerHost {
fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "analytics requires mounting default docker socket:", parsed.Host)
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func TestSigningJWT(t *testing.T) {
})

t.Run("signs default service_role key", func(t *testing.T) {
anonToken := CustomClaims{Role: "service_role"}.NewToken()
signed, err := anonToken.SignedString([]byte(defaultJwtSecret))
serviceToken := CustomClaims{Role: "service_role"}.NewToken()
signed, err := serviceToken.SignedString([]byte(defaultJwtSecret))
assert.NoError(t, err)
assert.Equal(t, defaultServiceRoleKey, signed)
})
Expand Down

0 comments on commit f5a667c

Please sign in to comment.