support for defining docker network opts
This commit is contained in:
@@ -42,18 +42,19 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Runner struct {
|
Runner struct {
|
||||||
Name string `envconfig:"DRONE_RUNNER_NAME"`
|
Name string `envconfig:"DRONE_RUNNER_NAME"`
|
||||||
Capacity int `envconfig:"DRONE_RUNNER_CAPACITY" default:"2"`
|
Capacity int `envconfig:"DRONE_RUNNER_CAPACITY" default:"2"`
|
||||||
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
|
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
|
||||||
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
|
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
|
||||||
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
|
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
|
||||||
Secrets map[string]string `envconfig:"DRONE_RUNNER_SECRETS"`
|
Secrets map[string]string `envconfig:"DRONE_RUNNER_SECRETS"`
|
||||||
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
|
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
|
||||||
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
|
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
|
||||||
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
|
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
|
||||||
Networks []string `envconfig:"DRONE_RUNNER_NETWORKS"`
|
Networks []string `envconfig:"DRONE_RUNNER_NETWORKS"`
|
||||||
Privileged []string `envconfig:"DRONE_RUNNER_PRIVILEGED_IMAGES"`
|
NetworkOpts map[string]string `envconfig:"DRONE_RUNNER_NETWORK_OPTS"`
|
||||||
Clone string `envconfig:"DRONE_RUNNER_CLONE_IMAGE"`
|
Privileged []string `envconfig:"DRONE_RUNNER_PRIVILEGED_IMAGES"`
|
||||||
|
Clone string `envconfig:"DRONE_RUNNER_CLONE_IMAGE"`
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform struct {
|
Platform struct {
|
||||||
|
|||||||
@@ -120,10 +120,11 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
config.Limit.Trusted,
|
config.Limit.Trusted,
|
||||||
),
|
),
|
||||||
Compiler: &compiler.Compiler{
|
Compiler: &compiler.Compiler{
|
||||||
Clone: config.Runner.Clone,
|
Clone: config.Runner.Clone,
|
||||||
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
||||||
Networks: config.Runner.Networks,
|
Networks: config.Runner.Networks,
|
||||||
Volumes: config.Runner.Volumes,
|
NetworkOpts: config.Runner.NetworkOpts,
|
||||||
|
Volumes: config.Runner.Volumes,
|
||||||
Resources: compiler.Resources{
|
Resources: compiler.Resources{
|
||||||
Memory: config.Resources.Memory,
|
Memory: config.Resources.Memory,
|
||||||
MemorySwap: config.Resources.MemorySwap,
|
MemorySwap: config.Resources.MemorySwap,
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ type Compiler struct {
|
|||||||
// attached to each pipeline container.
|
// attached to each pipeline container.
|
||||||
Networks []string
|
Networks []string
|
||||||
|
|
||||||
|
// NetworkOpts provides a set of network options that
|
||||||
|
// are used when creating the docker network.
|
||||||
|
NetworkOpts map[string]string
|
||||||
|
|
||||||
// Volumes provides a set of volumes that should be
|
// Volumes provides a set of volumes that should be
|
||||||
// mounted to each pipeline container.
|
// mounted to each pipeline container.
|
||||||
Volumes map[string]string
|
Volumes map[string]string
|
||||||
@@ -154,8 +158,9 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
|||||||
|
|
||||||
spec := &engine.Spec{
|
spec := &engine.Spec{
|
||||||
Network: engine.Network{
|
Network: engine.Network{
|
||||||
ID: random(),
|
ID: random(),
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
|
Options: c.NetworkOpts,
|
||||||
},
|
},
|
||||||
Platform: engine.Platform{
|
Platform: engine.Platform{
|
||||||
OS: pipeline.Platform.OS,
|
OS: pipeline.Platform.OS,
|
||||||
|
|||||||
@@ -83,8 +83,9 @@ func (e *Docker) Setup(ctx context.Context, specv runtime.Spec) error {
|
|||||||
driver = "nat"
|
driver = "nat"
|
||||||
}
|
}
|
||||||
_, err := e.client.NetworkCreate(ctx, spec.Network.ID, types.NetworkCreate{
|
_, err := e.client.NetworkCreate(ctx, spec.Network.ID, types.NetworkCreate{
|
||||||
Driver: driver,
|
Driver: driver,
|
||||||
Labels: spec.Network.Labels,
|
Options: spec.Network.Options,
|
||||||
|
Labels: spec.Network.Labels,
|
||||||
})
|
})
|
||||||
|
|
||||||
return errors.TrimExtraInfo(err)
|
return errors.TrimExtraInfo(err)
|
||||||
|
|||||||
@@ -117,8 +117,9 @@ type (
|
|||||||
|
|
||||||
// Network that is created and attached to containers
|
// Network that is created and attached to containers
|
||||||
Network struct {
|
Network struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Labels map[string]string `json:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty"`
|
||||||
|
Options map[string]string `json:"options,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auth defines dockerhub authentication credentials.
|
// Auth defines dockerhub authentication credentials.
|
||||||
|
|||||||
Reference in New Issue
Block a user