コード例 #1
0
        public Container(
            DockerClient dockerClient,
            string name,
            string imageName,
            string tag = "latest",
            IDictionary <string, string> environmentVariables = null,
            IDictionary <ushort, ushort> ports = null,
            bool isDockerInDocker              = false,
            bool reuseContainer                = false,
            IContainerWaiter containerWaiter   = null,
            IContainerCleaner containerCleaner = null,
            ILogger logger            = null,
            IList <string> entrypoint = null,
            IContainerInitializer containerInitializer = null)
        {
            Name             = name;
            DockerClient     = dockerClient;
            Logger           = logger;
            IsDockerInDocker = isDockerInDocker;
            ImageName        = imageName ?? throw new ArgumentNullException(nameof(imageName));
            Tag = tag;
            EnvironmentVariables = environmentVariables ?? new Dictionary <string, string>();
            Ports                 = ports;
            _containerWaiter      = containerWaiter;
            _containerInitializer = containerInitializer;
            _containerCleaner     = containerCleaner;
            _reuseContainer       = reuseContainer;

            Entrypoint = entrypoint;
        }
コード例 #2
0
 public PostgresContainer(
     DockerClient dockerClient,
     string name,
     string userName,
     string password,
     string imageName = "postgres",
     string tag       = "latest",
     IDictionary <string, string> environmentVariables = null,
     IDictionary <ushort, ushort> ports = null,
     bool isDockerInDocker              = false,
     bool reuseContainer                = false,
     IContainerWaiter containerWaiter   = null,
     IContainerCleaner containerCleaner = null,
     ILogger logger = null)
     : base(
         dockerClient,
         name,
         imageName,
         tag,
         environmentVariables,
         ports,
         isDockerInDocker,
         reuseContainer,
         containerWaiter,
         containerCleaner,
         logger)
 {
     _userName = userName;
     _password = password;
 }
コード例 #3
0
 public ContainerFromDockerfile(DockerClient dockerClient,
                                string name,
                                string dockerfile,
                                IDictionary <string, string> buildArgs = null,
                                string context = ".",
                                IDictionary <string, string> environmentVariables = null,
                                IDictionary <ushort, ushort> ports = null,
                                bool isDockerInDocker              = false,
                                bool reuseContainer                = false,
                                IContainerWaiter containerWaiter   = null,
                                IContainerCleaner containerCleaner = null,
                                ILogger logger = null)
     : base(dockerClient, name, name, "dev", environmentVariables, ports, isDockerInDocker, reuseContainer, containerWaiter, containerCleaner, logger)
 {
     Dockerfile = dockerfile;
     BuildArgs  = buildArgs;
     Context    = context;
 }
        public MongoSingleReplicaSetContainer(
            DockerClient dockerClient,
            string name,
            string replicaSetName,
            string imageName,
            string tag  = "latest",
            ushort?port = null,
            IDictionary <string, string> environmentVariables = null,
            bool isDockerInDocker              = false,
            bool reuseContainer                = false,
            IContainerWaiter containerWaiter   = null,
            IContainerCleaner containerCleaner = null,
            ILogger logger = null)
            : base(
                dockerClient,
                name,
                imageName,
                tag,
                environmentVariables,
                port == null ? new Dictionary <ushort, ushort> {
            { 27017, 27017 }
        } : new Dictionary <ushort, ushort> {
            { port.Value, port.Value }
        },
                isDockerInDocker,
                reuseContainer,
                containerWaiter,
                containerCleaner,
                logger,
                port == null ? new List <string> {
            "/usr/bin/mongod", "--bind_ip_all", "--replSet", replicaSetName
        } : new List <string> {
            "/usr/bin/mongod", "--bind_ip_all", "--replSet", replicaSetName, "--port", port.Value.ToString()
        },
                new MongoSingleReplicaSetContainerInitializer(replicaSetName))
        {
            if (string.IsNullOrWhiteSpace(replicaSetName))
            {
                throw new ArgumentException("The value must be specified", nameof(replicaSetName));
            }

            _replicaSetName = replicaSetName;
            _port           = port;
        }
コード例 #5
0
        public IDockerEnvironmentBuilder AddContainer(string name, string imageName, string tag = "latest", IDictionary <string, string> environmentVariables = null, IDictionary <ushort, ushort> ports = null, bool reuseContainer = false, IContainerWaiter containerWaiter = null, IContainerCleaner containerCleaner = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrEmpty(imageName))
            {
                throw new ArgumentNullException(nameof(imageName));
            }

            var container = new Container(DockerClient, name.GetContainerName(EnvironmentName), imageName, tag, environmentVariables, ports, IsDockerInDocker, reuseContainer, containerWaiter, containerCleaner, Logger);

            AddDependency(container);

            return(this);
        }
コード例 #6
0
        public IDockerEnvironmentBuilder AddFromDockerfile(string name, string dockerfile, IDictionary <string, string> buildArgs = null, string context = ".", IDictionary <string, string> environmentVariables = null, IDictionary <ushort, ushort> ports = null, bool reuseContainer = false, IContainerWaiter containerWaiter = null, IContainerCleaner containerCleaner = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (string.IsNullOrEmpty(dockerfile))
            {
                throw new ArgumentNullException(nameof(dockerfile));
            }

            var container = new ContainerFromDockerfile(DockerClient, name.GetContainerName(EnvironmentName), dockerfile, buildArgs, context, environmentVariables, ports, IsDockerInDocker, reuseContainer, containerWaiter, containerCleaner, Logger);

            AddDependency(container);

            return(this);
        }