Add a few configuration fields
Configurable path for application storage, SSH IP and HTTP IP
This commit is contained in:
parent
6c8f80b326
commit
bc7969bcce
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"Rostifile"
|
||||
]
|
||||
}
|
@ -9,7 +9,8 @@ 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
|
||||
AppsBindIPHTTP string `envconfig:"APPS_BIND_IP_HTTP" default:"0.0.0.0"` // On what IP apps' HTTP port gonna be bound
|
||||
AppsBindIPSSH string `envconfig:"APPS_BIND_IP_SSH" default:"0.0.0.0"` // On what IP apps' SSH ports gonna be bound
|
||||
}
|
||||
|
||||
// GetConfig return configuration created based on environment variables
|
||||
|
@ -34,7 +34,8 @@ const dockerAPIVersion = "1.38"
|
||||
|
||||
// Driver keeps everything for connection to Docker
|
||||
type Driver struct {
|
||||
BindIP string // IP to which containers are bound
|
||||
BindIPHTTP string // IP to which containers are bound
|
||||
BindIPSSH string // IP to which containers are bound
|
||||
}
|
||||
|
||||
func (d *Driver) getClient() (*dockerClient.Client, error) {
|
||||
@ -320,7 +321,7 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
||||
portBindings := nat.PortMap{
|
||||
"8000/tcp": []nat.PortBinding{
|
||||
{
|
||||
HostIP: d.BindIP,
|
||||
HostIP: d.BindIPHTTP,
|
||||
HostPort: strconv.Itoa(HTTPPort),
|
||||
},
|
||||
},
|
||||
@ -329,7 +330,7 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i
|
||||
if SSHPort != 0 {
|
||||
portBindings["22/tcp"] = []nat.PortBinding{
|
||||
{
|
||||
HostIP: d.BindIP,
|
||||
HostIP: d.BindIPSSH,
|
||||
HostPort: strconv.Itoa(SSHPort),
|
||||
},
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ type Container struct {
|
||||
func (c *Container) getDriver() *Driver {
|
||||
config := common.GetConfig()
|
||||
driver := &Driver{
|
||||
BindIP: config.AppsBindIP,
|
||||
BindIPHTTP: config.AppsBindIPHTTP,
|
||||
BindIPSSH: config.AppsBindIPSSH,
|
||||
}
|
||||
return driver
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user