示例#1
0
        public static Result <string> Build(this IHostService host, string name, string tag, string workdir = null,
                                            ContainerBuildParams prms = null)
        {
            var res = host.Host.Build(name, tag, workdir, prms, host.Certificates);

            return(res.Success ? res.Data[0].ToSuccess() : string.Empty.ToFailure(res.Error, res.Log));
        }
示例#2
0
        public static CommandResponse <IList <string> > Build(this DockerUri host, string name, string tag, string workdir = null,
                                                              ContainerBuildParams prms      = null,
                                                              ICertificatePaths certificates = null)
        {
            if (null == tag)
            {
                tag = "latest";
            }

            if (string.IsNullOrEmpty(workdir))
            {
                workdir = ".";
            }

            var options = string.Empty;

            if (null != prms?.Tags)
            {
                if (!prms.Tags.Any(x => x == tag))
                {
                    options = $"-t {name}:{tag}";
                }
            }

            if (null != prms)
            {
                options += $" {prms}";
            }

            return
                (new ProcessExecutor <StringListResponseParser, IList <string> >(
                     "docker".ResolveBinary(),
                     $"{host.RenderBaseArgs(certificates)} build {options} {workdir}").Execute());
        }