From bc7969bcceb8fb8ce26fdc411d598c34bb415cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Sat, 30 Jan 2021 12:33:57 +0100 Subject: [PATCH] Add a few configuration fields Configurable path for application storage, SSH IP and HTTP IP --- .vscode/settings.json | 5 +++++ common/config.go | 5 +++-- docker/docker.go | 7 ++++--- docker/types.go | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bd2224a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "Rostifile" + ] +} diff --git a/common/config.go b/common/config.go index 69b30d0..41e7cfa 100644 --- a/common/config.go +++ b/common/config.go @@ -8,8 +8,9 @@ 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 + AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located + 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 diff --git a/docker/docker.go b/docker/docker.go index c6a9afd..12a0d71 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -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), }, } diff --git a/docker/types.go b/docker/types.go index b919dc7..205645d 100644 --- a/docker/types.go +++ b/docker/types.go @@ -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 }