Configurable IP address used to bind apps' ports
This commit is contained in:
parent
35fcfc759a
commit
6c8f80b326
@ -9,6 +9,7 @@ import (
|
||||
// Config keeps info about configuration of this daemon
|
||||
type Config struct {
|
||||
AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located
|
||||
AppsBindIP string `envconfig:"APPS_BIND_IP" default:"0.0.0.0"` // On what IP apps gonna be bound
|
||||
}
|
||||
|
||||
// GetConfig return configuration created based on environment variables
|
||||
|
@ -33,7 +33,9 @@ const podmanSock = "/run/podman/podman.sock"
|
||||
const dockerAPIVersion = "1.38"
|
||||
|
||||
// Driver keeps everything for connection to Docker
|
||||
type Driver struct{}
|
||||
type Driver struct {
|
||||
BindIP string // IP to which containers are bound
|
||||
}
|
||||
|
||||
func (d *Driver) getClient() (*dockerClient.Client, error) {
|
||||
var connectTo string
|
||||
@ -318,7 +320,7 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
||||
portBindings := nat.PortMap{
|
||||
"8000/tcp": []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
HostIP: d.BindIP,
|
||||
HostPort: strconv.Itoa(HTTPPort),
|
||||
},
|
||||
},
|
||||
@ -327,7 +329,7 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
||||
if SSHPort != 0 {
|
||||
portBindings["22/tcp"] = []nat.PortBinding{
|
||||
{
|
||||
HostIP: "0.0.0.0",
|
||||
HostIP: d.BindIP,
|
||||
HostPort: strconv.Itoa(SSHPort),
|
||||
},
|
||||
}
|
||||
|
@ -25,7 +25,10 @@ type Container struct {
|
||||
}
|
||||
|
||||
func (c *Container) getDriver() *Driver {
|
||||
driver := &Driver{}
|
||||
config := common.GetConfig()
|
||||
driver := &Driver{
|
||||
BindIP: config.AppsBindIP,
|
||||
}
|
||||
return driver
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user