mirror of https://github.com/docker/compose.git
Merge pull request #1435 from docker/more_composefile
add support for a few more composefile attributes
This commit is contained in:
commit
23b03af744
|
@ -50,6 +50,17 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
|
||||||
buildOptions.Pull = options.Pull
|
buildOptions.Pull = options.Pull
|
||||||
buildOptions.BuildArgs = options.Args
|
buildOptions.BuildArgs = options.Args
|
||||||
opts[imageName] = buildOptions
|
opts[imageName] = buildOptions
|
||||||
|
buildOptions.CacheFrom, err = build.ParseCacheEntry(service.Build.CacheFrom)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, image := range service.Build.CacheFrom {
|
||||||
|
buildOptions.CacheFrom = append(buildOptions.CacheFrom, bclient.CacheOptionsEntry{
|
||||||
|
Type: "registry",
|
||||||
|
Attrs: map[string]string{"ref": image},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import (
|
||||||
volume_api "github.com/docker/docker/api/types/volume"
|
volume_api "github.com/docker/docker/api/types/volume"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
|
"github.com/docker/go-units"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
@ -272,6 +273,31 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shmSize := int64(0)
|
||||||
|
if service.ShmSize != "" {
|
||||||
|
shmSize, err = strconv.ParseInt(service.ShmSize, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpfs := map[string]string{}
|
||||||
|
for _, t := range service.Tmpfs {
|
||||||
|
if arr := strings.SplitN(t, ":", 2); len(arr) > 1 {
|
||||||
|
tmpfs[arr[0]] = arr[1]
|
||||||
|
} else {
|
||||||
|
tmpfs[arr[0]] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var logConfig container.LogConfig
|
||||||
|
if service.Logging != nil {
|
||||||
|
logConfig = container.LogConfig{
|
||||||
|
Type: service.Logging.Driver,
|
||||||
|
Config: service.Logging.Options,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hostConfig := container.HostConfig{
|
hostConfig := container.HostConfig{
|
||||||
AutoRemove: autoRemove,
|
AutoRemove: autoRemove,
|
||||||
Binds: binds,
|
Binds: binds,
|
||||||
|
@ -282,20 +308,23 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
|
||||||
Init: service.Init,
|
Init: service.Init,
|
||||||
ReadonlyRootfs: service.ReadOnly,
|
ReadonlyRootfs: service.ReadOnly,
|
||||||
RestartPolicy: getRestartPolicy(service),
|
RestartPolicy: getRestartPolicy(service),
|
||||||
// ShmSize: , TODO
|
ShmSize: shmSize,
|
||||||
Sysctls: service.Sysctls,
|
Sysctls: service.Sysctls,
|
||||||
PortBindings: portBindings,
|
PortBindings: portBindings,
|
||||||
Resources: resources,
|
Resources: resources,
|
||||||
VolumeDriver: service.VolumeDriver,
|
VolumeDriver: service.VolumeDriver,
|
||||||
VolumesFrom: service.VolumesFrom,
|
VolumesFrom: service.VolumesFrom,
|
||||||
DNS: service.DNS,
|
DNS: service.DNS,
|
||||||
DNSSearch: service.DNSSearch,
|
DNSSearch: service.DNSSearch,
|
||||||
DNSOptions: service.DNSOpts,
|
DNSOptions: service.DNSOpts,
|
||||||
ExtraHosts: service.ExtraHosts,
|
ExtraHosts: service.ExtraHosts,
|
||||||
SecurityOpt: service.SecurityOpt,
|
SecurityOpt: service.SecurityOpt,
|
||||||
UsernsMode: container.UsernsMode(service.UserNSMode),
|
UsernsMode: container.UsernsMode(service.UserNSMode),
|
||||||
Privileged: service.Privileged,
|
Privileged: service.Privileged,
|
||||||
Isolation: container.Isolation(service.Isolation),
|
PidMode: container.PidMode(service.Pid),
|
||||||
|
Tmpfs: tmpfs,
|
||||||
|
Isolation: container.Isolation(service.Isolation),
|
||||||
|
LogConfig: logConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
networkConfig := buildDefaultNetworkConfig(service, networkMode, getContainerName(p.Name, service, number))
|
networkConfig := buildDefaultNetworkConfig(service, networkMode, getContainerName(p.Name, service, number))
|
||||||
|
@ -349,6 +378,37 @@ func getDeployResources(s types.ServiceConfig) container.Resources {
|
||||||
Driver: device.Driver,
|
Driver: device.Driver,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, device := range s.Devices {
|
||||||
|
// FIXME should use docker/cli parseDevice, unfortunately private
|
||||||
|
src := ""
|
||||||
|
dst := ""
|
||||||
|
permissions := "rwm"
|
||||||
|
arr := strings.Split(device, ":")
|
||||||
|
switch len(arr) {
|
||||||
|
case 3:
|
||||||
|
permissions = arr[2]
|
||||||
|
fallthrough
|
||||||
|
case 2:
|
||||||
|
dst = arr[1]
|
||||||
|
fallthrough
|
||||||
|
case 1:
|
||||||
|
src = arr[0]
|
||||||
|
}
|
||||||
|
resources.Devices = append(resources.Devices, container.DeviceMapping{
|
||||||
|
PathOnHost: src,
|
||||||
|
PathInContainer: dst,
|
||||||
|
CgroupPermissions: permissions,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, u := range s.Ulimits {
|
||||||
|
resources.Ulimits = append(resources.Ulimits, &units.Ulimit{
|
||||||
|
Name: name,
|
||||||
|
Hard: int64(u.Hard),
|
||||||
|
Soft: int64(u.Soft),
|
||||||
|
})
|
||||||
|
}
|
||||||
return resources
|
return resources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue