Exemplo n.º 1
0
        public static Task Wait(WaitForDockerConfig config)
        {
            config = config ?? new WaitForDockerConfig();
            var composeYaml  = DockerFilesReader.ReadComposeContent(config.DockerComposeDirPath, config.ComposeFileName);
            var composeJson  = new JsonComposeConverter().Convert(composeYaml);
            var servicePorts = new JsonComposeServicesPortsExtractor().ExtractServicePorts(composeJson).ToArray();

            var killCommand = DockerCommandBuilder.BuildDockerKillCommand(config, servicePorts);

            ShellExecutorFactory.GetShellExecutor(config.Logger).Execute(killCommand, DockerConsts.DockerComposeKill);
            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public static async Task Wait(WaitForDockerConfig config)
        {
            config = config ?? new WaitForDockerConfig();
            var logger = config.Logger;

            logger.Log("Wait for docker has been started..");
            var composeYaml  = DockerFilesReader.ReadComposeContent(config.DockerComposeDirPath, config.ComposeFileName);
            var composeJson  = new JsonComposeConverter().Convert(composeYaml);
            var servicePorts = new JsonComposeServicesPortsExtractor().ExtractServicePorts(composeJson).ToArray();

            logger.Log($"Checking is any port is already occupied before {DockerConsts.DockerCompose} execution..");
            await DockerHealthCheckRunner.RunPreComposeHealthChecks(servicePorts, config.Logger);

            config.ExtendWithDefaultHealthChecks(servicePorts);
            var composeCommand = DockerCommandBuilder.BuildComposeCommand(config);

            ShellExecutorFactory.GetShellExecutor(config.Logger).Execute(composeCommand, DockerConsts.DockerCompose);

            await DockerHealthCheckRunner.RunPostComposeHealthChecks(config.HealthCheckers);

            logger.Log("All health checks returns success.");
            logger.Log("Wait for docker has been finished..");
        }