-
Notifications
You must be signed in to change notification settings - Fork 179
/
proxy.go
49 lines (34 loc) · 883 Bytes
/
proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package manifest1
import "fmt"
type Proxy struct {
Name string
Balancer int
Container int
Protocol string
Host string
Network string
Proxy bool
Secure bool
}
func (p *Proxy) Start() error {
Docker("rm", "-f", p.Name).Run()
args := []string{"run"}
args = append(args, "--rm", "--name", p.Name)
args = append(args, "-p", fmt.Sprintf("%d:%d", p.Balancer, p.Balancer))
// Attach proxy container to custom docker network, if configured
if p.Network != "" {
args = append(args, "--net", p.Network)
}
args = append(args, "--link", fmt.Sprintf("%s:host", p.Host))
args = append(args, "convox/proxy", fmt.Sprintf("%d", p.Balancer), fmt.Sprintf("%d", p.Container), p.Protocol)
if p.Proxy {
args = append(args, "proxy")
}
if p.Secure {
args = append(args, "secure")
}
cmd := Docker(args...)
err := cmd.Start()
go cmd.Wait()
return err
}