|
@@ -12,6 +12,7 @@ import (
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/api/types/container"
|
|
|
"github.com/docker/docker/api/types/mount"
|
|
"github.com/docker/docker/api/types/mount"
|
|
|
|
|
+ "github.com/docker/go-connections/nat"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// load existing urbits from config json
|
|
// load existing urbits from config json
|
|
@@ -62,7 +63,7 @@ func urbitContainerConf(containerName string) (container.Config, container.HostC
|
|
|
shipConf := config.UrbitConf(containerName)
|
|
shipConf := config.UrbitConf(containerName)
|
|
|
// todo: this BootStatus doesnt actually have anythin to do with pack and meld right now
|
|
// todo: this BootStatus doesnt actually have anythin to do with pack and meld right now
|
|
|
act := shipConf.BootStatus
|
|
act := shipConf.BootStatus
|
|
|
- // get the correct startup script based on act
|
|
|
|
|
|
|
+ // get the correct startup script based on BootStatus val
|
|
|
switch act {
|
|
switch act {
|
|
|
case "boot":
|
|
case "boot":
|
|
|
scriptContent = defaults.StartScript
|
|
scriptContent = defaults.StartScript
|
|
@@ -73,7 +74,7 @@ func urbitContainerConf(containerName string) (container.Config, container.HostC
|
|
|
case "prep":
|
|
case "prep":
|
|
|
scriptContent = defaults.PrepScript
|
|
scriptContent = defaults.PrepScript
|
|
|
case "noboot":
|
|
case "noboot":
|
|
|
- return containerConfig, hostConfig, fmt.Errorf("%s marked noboot!",containerName)
|
|
|
|
|
|
|
+ return containerConfig, hostConfig, fmt.Errorf("%s marked noboot!", containerName)
|
|
|
default:
|
|
default:
|
|
|
return containerConfig, hostConfig, fmt.Errorf("Unknown action: %s", act)
|
|
return containerConfig, hostConfig, fmt.Errorf("Unknown action: %s", act)
|
|
|
}
|
|
}
|
|
@@ -107,6 +108,7 @@ func urbitContainerConf(containerName string) (container.Config, container.HostC
|
|
|
var httpPort string
|
|
var httpPort string
|
|
|
var amesPort string
|
|
var amesPort string
|
|
|
var network string
|
|
var network string
|
|
|
|
|
+ var portMap nat.PortMap
|
|
|
if shipConf.Network == "wireguard" {
|
|
if shipConf.Network == "wireguard" {
|
|
|
httpPort = string(shipConf.WgHTTPPort)
|
|
httpPort = string(shipConf.WgHTTPPort)
|
|
|
amesPort = string(shipConf.WgAmesPort)
|
|
amesPort = string(shipConf.WgAmesPort)
|
|
@@ -115,11 +117,21 @@ func urbitContainerConf(containerName string) (container.Config, container.HostC
|
|
|
httpPort = string(shipConf.HTTPPort)
|
|
httpPort = string(shipConf.HTTPPort)
|
|
|
amesPort = string(shipConf.AmesPort)
|
|
amesPort = string(shipConf.AmesPort)
|
|
|
network = "default"
|
|
network = "default"
|
|
|
|
|
+ httpPortStr := nat.Port(fmt.Sprintf(httpPort+"/tcp"))
|
|
|
|
|
+ amesPortStr := nat.Port(fmt.Sprintf(amesPort+"/udp"))
|
|
|
|
|
+ portMap = nat.PortMap{
|
|
|
|
|
+ httpPortStr: []nat.PortBinding{
|
|
|
|
|
+ {HostIP: "0.0.0.0", HostPort: httpPort},
|
|
|
|
|
+ },
|
|
|
|
|
+ amesPortStr: []nat.PortBinding{
|
|
|
|
|
+ {HostIP: "0.0.0.0", HostPort: amesPort},
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// finally construct the container config structs
|
|
// finally construct the container config structs
|
|
|
containerConfig = container.Config{
|
|
containerConfig = container.Config{
|
|
|
Image: desiredImage,
|
|
Image: desiredImage,
|
|
|
- Entrypoint: []string{scriptPath, shipName, "--loom=" + loomValue, "--dirname=" + dirnameValue, "--dev-mode="+ devMode, "--http-port=" + httpPort, "--port=" + amesPort},
|
|
|
|
|
|
|
+ Entrypoint: []string{scriptPath, shipName, "--loom=" + loomValue, "--dirname=" + dirnameValue, "--dev-mode=" + devMode, "--http-port=" + httpPort, "--port=" + amesPort},
|
|
|
}
|
|
}
|
|
|
mounts := []mount.Mount{
|
|
mounts := []mount.Mount{
|
|
|
{
|
|
{
|
|
@@ -131,6 +143,7 @@ func urbitContainerConf(containerName string) (container.Config, container.HostC
|
|
|
hostConfig = container.HostConfig{
|
|
hostConfig = container.HostConfig{
|
|
|
NetworkMode: container.NetworkMode(network),
|
|
NetworkMode: container.NetworkMode(network),
|
|
|
Mounts: mounts,
|
|
Mounts: mounts,
|
|
|
|
|
+ PortBindings: portMap,
|
|
|
}
|
|
}
|
|
|
return containerConfig, hostConfig, nil
|
|
return containerConfig, hostConfig, nil
|
|
|
}
|
|
}
|