diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 92c8fe5eb..b36a447ed 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -118,7 +118,7 @@ EOF`} func NewHostConfig() container.HostConfig { hostPort := strconv.FormatUint(uint64(utils.Config.Db.Port), 10) hostConfig := container.HostConfig{ - PortBindings: nat.PortMap{"5432/tcp": []nat.PortBinding{{HostPort: hostPort}}}, + PortBindings: nat.PortMap{"5432/tcp": []nat.PortBinding{{HostIP: utils.Config.Db.HostIP, HostPort: hostPort}}}, RestartPolicy: container.RestartPolicy{Name: container.RestartPolicyUnlessStopped}, Binds: []string{ utils.DbId + ":/var/lib/postgresql/data", diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 9819a181d..3adb238fd 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -195,6 +195,7 @@ EOF dockerInspectorPort := nat.Port(fmt.Sprintf("%d/tcp", dockerRuntimeInspectorPort)) exposedPorts[dockerInspectorPort] = struct{}{} portBindings[dockerInspectorPort] = []nat.PortBinding{{ + HostIP: utils.Config.EdgeRuntime.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.EdgeRuntime.InspectorPort), 10), }} } diff --git a/internal/start/start.go b/internal/start/start.go index cf4bc68fd..444e7e353 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -317,7 +317,7 @@ EOF }, container.HostConfig{ Binds: bind, - PortBindings: nat.PortMap{"4000/tcp": []nat.PortBinding{{HostPort: strconv.FormatUint(uint64(utils.Config.Analytics.Port), 10)}}}, + PortBindings: nat.PortMap{"4000/tcp": []nat.PortBinding{{HostIP: utils.Config.Analytics.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Analytics.Port), 10)}}}, RestartPolicy: container.RestartPolicy{Name: container.RestartPolicyUnlessStopped}, }, network.NetworkingConfig{ @@ -524,6 +524,7 @@ EOF container.HostConfig{ Binds: binds, PortBindings: nat.PortMap{nat.Port(fmt.Sprintf("%d/tcp", dockerPort)): []nat.PortBinding{{ + HostIP: utils.Config.Api.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Api.Port), 10)}, }}, RestartPolicy: container.RestartPolicy{Name: container.RestartPolicyUnlessStopped}, @@ -842,12 +843,12 @@ EOF // Start Mailpit if utils.Config.Inbucket.Enabled && !isContainerExcluded(utils.Config.Inbucket.Image, excluded) { - inbucketPortBindings := nat.PortMap{"8025/tcp": []nat.PortBinding{{HostPort: strconv.FormatUint(uint64(utils.Config.Inbucket.Port), 10)}}} + inbucketPortBindings := nat.PortMap{"8025/tcp": []nat.PortBinding{{HostIP: utils.Config.Inbucket.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Inbucket.Port), 10)}}} if utils.Config.Inbucket.SmtpPort != 0 { - inbucketPortBindings["1025/tcp"] = []nat.PortBinding{{HostPort: strconv.FormatUint(uint64(utils.Config.Inbucket.SmtpPort), 10)}} + inbucketPortBindings["1025/tcp"] = []nat.PortBinding{{HostIP: utils.Config.Inbucket.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Inbucket.SmtpPort), 10)}} } if utils.Config.Inbucket.Pop3Port != 0 { - inbucketPortBindings["1110/tcp"] = []nat.PortBinding{{HostPort: strconv.FormatUint(uint64(utils.Config.Inbucket.Pop3Port), 10)}} + inbucketPortBindings["1110/tcp"] = []nat.PortBinding{{HostIP: utils.Config.Inbucket.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Inbucket.Pop3Port), 10)}} } if _, err := utils.DockerStart( ctx, @@ -1154,7 +1155,7 @@ EOF }, }, container.HostConfig{ - PortBindings: nat.PortMap{"3000/tcp": []nat.PortBinding{{HostPort: strconv.FormatUint(uint64(utils.Config.Studio.Port), 10)}}}, + PortBindings: nat.PortMap{"3000/tcp": []nat.PortBinding{{HostIP: utils.Config.Studio.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Studio.Port), 10)}}}, RestartPolicy: container.RestartPolicy{Name: container.RestartPolicyUnlessStopped}, }, network.NetworkingConfig{ @@ -1230,6 +1231,7 @@ EOF }, container.HostConfig{ PortBindings: nat.PortMap{nat.Port(fmt.Sprintf("%d/tcp", dockerPort)): []nat.PortBinding{{ + HostIP: utils.Config.Db.Pooler.HostIP, HostPort: strconv.FormatUint(uint64(utils.Config.Db.Pooler.Port), 10)}, }}, RestartPolicy: container.RestartPolicy{Name: container.RestartPolicyUnlessStopped}, diff --git a/pkg/config/api.go b/pkg/config/api.go index e294a38c6..2d109301a 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -18,6 +18,7 @@ type ( Image string `toml:"-"` KongImage string `toml:"-"` Port uint16 `toml:"port"` + HostIP string `toml:"host_ip"` Tls tlsKong `toml:"tls"` // TODO: replace [auth|studio].api_url ExternalUrl string `toml:"external_url"` diff --git a/pkg/config/config.go b/pkg/config/config.go index 6e9ef96bb..840b98aae 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -172,6 +172,7 @@ type ( Enabled bool `toml:"enabled"` Image string `toml:"-"` Port uint16 `toml:"port"` + HostIP string `toml:"host_ip"` ApiUrl string `toml:"api_url"` OpenaiApiKey Secret `toml:"openai_api_key"` PgmetaImage string `toml:"-"` @@ -181,6 +182,7 @@ type ( Enabled bool `toml:"enabled"` Image string `toml:"-"` Port uint16 `toml:"port"` + HostIP string `toml:"host_ip"` SmtpPort uint16 `toml:"smtp_port"` Pop3Port uint16 `toml:"pop3_port"` AdminEmail string `toml:"admin_email"` @@ -192,6 +194,7 @@ type ( Image string `toml:"-"` Policy RequestPolicy `toml:"policy"` InspectorPort uint16 `toml:"inspector_port"` + HostIP string `toml:"host_ip"` Secrets SecretsConfig `toml:"secrets"` DenoVersion uint `toml:"deno_version"` } @@ -212,6 +215,7 @@ type ( Image string `toml:"-"` VectorImage string `toml:"-"` Port uint16 `toml:"port"` + HostIP string `toml:"host_ip"` Backend LogflareBackend `toml:"backend"` GcpProjectId string `toml:"gcp_project_id"` GcpProjectNumber string `toml:"gcp_project_number"` @@ -334,6 +338,7 @@ func NewConfig(editors ...ConfigEditor) config { Api: api{ Image: Images.Postgrest, KongImage: Images.Kong, + HostIP: "127.0.0.1", Tls: tlsKong{ CertContent: kongCert, KeyContent: kongKey, @@ -342,12 +347,14 @@ func NewConfig(editors ...ConfigEditor) config { Db: db{ Image: Images.Pg, Password: "postgres", + HostIP: "127.0.0.1", RootKey: Secret{ Value: "d4dc5b6d4a1d6a10b2c1e76112c994d65db7cec380572cc1839624d4be3fa275", }, Pooler: pooler{ Image: Images.Supavisor, TenantId: "pooler-dev", + HostIP: "127.0.0.1", EncryptionKey: "12345678901234567890123456789032", SecretKeyBase: "EAx3IQ/wRG1v47ZD4NE4/9RzBI8Jmil3x0yhcW4V2NHBP6c2iPIzwjofi2Ep4HIG", }, @@ -389,22 +396,26 @@ func NewConfig(editors ...ConfigEditor) config { }, Inbucket: inbucket{ Image: Images.Inbucket, + HostIP: "127.0.0.1", AdminEmail: "admin@email.com", SenderName: "Admin", }, Studio: studio{ Image: Images.Studio, + HostIP: "127.0.0.1", PgmetaImage: Images.Pgmeta, }, Analytics: analytics{ Image: Images.Logflare, VectorImage: Images.Vector, + HostIP: "127.0.0.1", ApiKey: "api-key", // Defaults to bigquery for backwards compatibility with existing config.toml Backend: LogflareBigQuery, }, EdgeRuntime: edgeRuntime{ - Image: Images.EdgeRuntime, + Image: Images.EdgeRuntime, + HostIP: "127.0.0.1", }, }} for _, apply := range editors { diff --git a/pkg/config/db.go b/pkg/config/db.go index b2b947667..8605f1f1d 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -77,6 +77,7 @@ type ( db struct { Image string `toml:"-"` Port uint16 `toml:"port"` + HostIP string `toml:"host_ip"` ShadowPort uint16 `toml:"shadow_port"` MajorVersion uint `toml:"major_version"` Password string `toml:"-"` @@ -103,6 +104,7 @@ type ( Enabled bool `toml:"enabled"` Image string `toml:"-"` Port uint16 `toml:"port"` + HostIP string `toml:"host_ip"` PoolMode PoolMode `toml:"pool_mode"` DefaultPoolSize uint `toml:"default_pool_size"` MaxClientConn uint `toml:"max_client_conn"`