示例#1
0
        public void AttachAzureFileShare(IAzureFileShare azureFileShare)
        {
            MountVolumes mountVolumes = EnsureMountVolumes();

            if (mountVolumes.AzureFileShares == null)
            {
                mountVolumes.AzureFileShares = new List <AzureFileShareReference>();
            }
            mountVolumes.AzureFileShares.Add(azureFileShare.Inner);
        }
示例#2
0
        public void AttachFileServer(IFileServer fileServer)
        {
            MountVolumes mountVolumes = EnsureMountVolumes();

            if (mountVolumes.FileServers == null)
            {
                mountVolumes.FileServers = new List <FileServerReference>();
            }
            mountVolumes.FileServers.Add(fileServer.Inner);
        }
示例#3
0
        public void AttachAzureBlobFileSystem(IAzureBlobFileSystem azureBlobFileSystem)
        {
            MountVolumes mountVolumes = EnsureMountVolumes();

            if (mountVolumes.AzureBlobFileSystems == null)
            {
                mountVolumes.AzureBlobFileSystems = new List <AzureBlobFileSystemReference>();
            }
            mountVolumes.AzureBlobFileSystems.Add(azureBlobFileSystem.Inner);
        }
示例#4
0
        public BatchAIJobImpl WithUnmanagedFileSystem(string mountCommand, string relativeMountPath)
        {
            MountVolumes mountVolumes = EnsureMountVolumes();

            if (mountVolumes.UnmanagedFileSystems == null)
            {
                mountVolumes.UnmanagedFileSystems = new List <UnmanagedFileSystemReference>();
            }
            mountVolumes.UnmanagedFileSystems.Add(new UnmanagedFileSystemReference(mountCommand, relativeMountPath));
            return(this);
        }
示例#5
0
        public void ExpandProperties(Variables variables)
        {
            // Expand port mapping
            variables.ExpandValues(UserPortMappings);

            // Expand volume mounts
            variables.ExpandValues(UserMountVolumes);
            foreach (var volume in UserMountVolumes.Values)
            {
                // After mount volume variables are expanded, they are final
                MountVolumes.Add(new MountVolume(volume));
            }
        }
示例#6
0
        public ContainerInfo(IHostContext hostContext, Pipelines.JobContainer container, bool isJobContainer = true, string networkAlias = null)
        {
            this.ContainerName = container.Alias;

            string containerImage = container.Image;

            ArgUtil.NotNullOrEmpty(containerImage, nameof(containerImage));

            this.ContainerImage         = containerImage;
            this.ContainerDisplayName   = $"{container.Alias}_{Pipelines.Validation.NameValidation.Sanitize(containerImage)}_{Guid.NewGuid().ToString("N").Substring(0, 6)}";
            this.ContainerCreateOptions = container.Options;
            _environmentVariables       = container.Environment;
            this.IsJobContainer         = isJobContainer;
            this.ContainerNetworkAlias  = networkAlias;
            this.RegistryAuthUsername   = container.Credentials?.Username;
            this.RegistryAuthPassword   = container.Credentials?.Password;
            this.RegistryServer         = DockerUtil.ParseRegistryHostnameFromImageName(this.ContainerImage);

#if OS_WINDOWS
            _pathMappings.Add(new PathMapping(hostContext.GetDirectory(WellKnownDirectory.Work), "C:\\__w"));
            _pathMappings.Add(new PathMapping(hostContext.GetDirectory(WellKnownDirectory.Tools), "C:\\__t")); // Tool cache folder may come from ENV, so we need a unique folder to avoid collision
            _pathMappings.Add(new PathMapping(hostContext.GetDirectory(WellKnownDirectory.Externals), "C:\\__e"));
            // add -v '\\.\pipe\docker_engine:\\.\pipe\docker_engine' when they are available (17.09)
#else
            _pathMappings.Add(new PathMapping(hostContext.GetDirectory(WellKnownDirectory.Work), "/__w"));
            _pathMappings.Add(new PathMapping(hostContext.GetDirectory(WellKnownDirectory.Tools), "/__t")); // Tool cache folder may come from ENV, so we need a unique folder to avoid collision
            _pathMappings.Add(new PathMapping(hostContext.GetDirectory(WellKnownDirectory.Externals), "/__e"));
            if (this.IsJobContainer)
            {
                this.MountVolumes.Add(new MountVolume("/var/run/docker.sock", "/var/run/docker.sock"));
            }
#endif
            if (container.Ports?.Count > 0)
            {
                foreach (var port in container.Ports)
                {
                    UserPortMappings[port] = port;
                }
            }
            if (container.Volumes?.Count > 0)
            {
                foreach (var volume in container.Volumes)
                {
                    UserMountVolumes[volume] = volume;
                    MountVolumes.Add(new MountVolume(volume));
                }
            }

            UpdateWebProxyEnv(hostContext.WebProxy);
        }
示例#7
0
        public void ExpandProperties(Variables variables)
        {
            // Expand port mapping
            variables.ExpandValues(UserPortMappings);

            // Expand volume mounts
            variables.ExpandValues(UserMountVolumes);
            foreach (var volume in UserMountVolumes.Values)
            {
                // After mount volume variables are expanded, they are final
                MountVolumes.Add(new MountVolume(volume));
            }

            // Expand env vars
            variables.ExpandValues(ContainerEnvironmentVariables);

            // Expand image and options strings
            ContainerImage         = variables.ExpandValue(nameof(ContainerImage), ContainerImage);
            ContainerCreateOptions = variables.ExpandValue(nameof(ContainerCreateOptions), ContainerCreateOptions);
        }