Fix docker TLS, update readme and config file
This commit is contained in:
parent
5539f63ba5
commit
12baa7a81a
4 changed files with 35 additions and 6 deletions
|
@ -122,9 +122,11 @@ from=""
|
||||||
user=""
|
user=""
|
||||||
pass=""
|
pass=""
|
||||||
|
|
||||||
[worker]
|
[docker]
|
||||||
cert=""
|
cert=""
|
||||||
key=""
|
key=""
|
||||||
|
|
||||||
|
[worker]
|
||||||
nodes=[
|
nodes=[
|
||||||
"unix:///var/run/docker.sock",
|
"unix:///var/run/docker.sock",
|
||||||
"unix:///var/run/docker.sock"
|
"unix:///var/run/docker.sock"
|
||||||
|
|
|
@ -64,9 +64,11 @@ datasource="/var/lib/drone/drone.sqlite"
|
||||||
# user=""
|
# user=""
|
||||||
# pass=""
|
# pass=""
|
||||||
|
|
||||||
# [worker]
|
# [docker]
|
||||||
# cert=""
|
# cert=""
|
||||||
# key=""
|
# key=""
|
||||||
|
|
||||||
|
# [worker]
|
||||||
# nodes=[
|
# nodes=[
|
||||||
# "unix:///var/run/docker.sock",
|
# "unix:///var/run/docker.sock",
|
||||||
# "unix:///var/run/docker.sock"
|
# "unix:///var/run/docker.sock"
|
||||||
|
|
|
@ -34,6 +34,10 @@ import (
|
||||||
"github.com/drone/drone/server/worker/pool"
|
"github.com/drone/drone/server/worker/pool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DockerTLSWarning = `WARINING: Docker TLS cert or key not given, this may cause a build errors`
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// commit sha for the current build, set by
|
// commit sha for the current build, set by
|
||||||
// the compile process.
|
// the compile process.
|
||||||
|
@ -61,9 +65,9 @@ var (
|
||||||
pub *pubsub.PubSub
|
pub *pubsub.PubSub
|
||||||
|
|
||||||
// Docker configuration details.
|
// Docker configuration details.
|
||||||
dockercrt = config.String("docker-cert", "")
|
dockercert = config.String("docker-cert", "")
|
||||||
dockerkey = config.String("docker-key", "")
|
dockerkey = config.String("docker-key", "")
|
||||||
nodes StringArr
|
nodes StringArr
|
||||||
|
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
|
|
||||||
|
@ -117,7 +121,14 @@ func main() {
|
||||||
workers.Allocate(docker.New())
|
workers.Allocate(docker.New())
|
||||||
} else {
|
} else {
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
workers.Allocate(docker.NewHost(node))
|
if strings.HasPrefix(node, "unix://") {
|
||||||
|
workers.Allocate(docker.NewHost(node))
|
||||||
|
} else if *dockercert != "" && *dockerkey != "" {
|
||||||
|
workers.Allocate(docker.NewHostCertFile(node, *dockercert, *dockerkey))
|
||||||
|
} else {
|
||||||
|
fmt.Println(DockerTLSWarning)
|
||||||
|
workers.Allocate(docker.NewHost(node))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,20 @@ func NewHost(host string) *Docker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewHostCertFile(host, cert, key string) *Docker {
|
||||||
|
docker_node, err := docker.NewHostCertFile(host, cert, key)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Docker{
|
||||||
|
UUID: uuid.New(),
|
||||||
|
Kind: dockerKind,
|
||||||
|
Created: time.Now().UTC().Unix(),
|
||||||
|
docker: docker_node,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Docker) Do(c context.Context, r *worker.Work) {
|
func (d *Docker) Do(c context.Context, r *worker.Work) {
|
||||||
|
|
||||||
// ensure that we can recover from any panics to
|
// ensure that we can recover from any panics to
|
||||||
|
|
Loading…
Reference in a new issue