Exemple #1
0
        public override bool IsHealthy(Context context)
        {
            var console = context.Console;

            console.Write("Docker ... ");
            var cli = new DockerCli(context.Shell);

            try
            {
                var dockerVersion = cli.Run("--version", "getting Docker CLI version").Trim();
                console.WriteLine(dockerVersion);

                var dockerInfo = cli.Run("info", "getting Docker info");

                console.Write("Docker host OS ... ");
                context.Console.WriteLine(new Regex(@"Operating System:\s*(.+)", RegexOptions.Multiline)
                                          .Match(dockerInfo).Groups[1].ToString());

                console.Write("Docker container OS ... ");
                context.Console.WriteLine(new Regex(@"OSType:\s*(.+)", RegexOptions.Multiline)
                                          .Match(dockerInfo).Groups[1].ToString());

                return(true);
            }
            catch (CliException e)
            {
                context.Console.WriteLine($"!!! {e.Message}");
                return(false);
            }
            catch (ShellException)
            {
                context.Console.WriteLine($"!!! {cli.Command} command not found");
                return(false);
            }
        }
Exemple #2
0
        public void DeployApp(string app)
        {
            _dotnetCli.Run($"publish -f {HardCodedFramework}", "publishing dotnet app");
            var dotnetImage = _context.Target.GetProperty("dotnetRuntimeImage");
            var projectDll  =
                $"bin/Debug/{HardCodedFramework}/publish/{Path.GetFileName(_context.ProjectDirectory)}.dll";
            const string appDir  = "/app";
            var          mount   = $"{Path.GetFullPath(_context.ProjectDirectory)}:{appDir}";
            var          portMap = $"{HardCodedLocalPort}:{HardCodedRemotePort}";

            _dockerCli.Run(
                $"run --name {app} --volume {mount} --publish {portMap} --detach --rm {dotnetImage} dotnet {appDir}/{projectDll}",
                "running app in Docker container");
        }
Exemple #3
0
 public void DeploySetup()
 {
     _dockerCli.Run(
         $"network create {GetNetworkName()}",
         "creating network");
 }