vsts + XX云服务器构建netcore+docker持续集成交付部署
<div id="7954-1526369583278" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="font-size: 32px; font-weight: bold">持续集成交付部署是什么意思,它给我们带来什么好处?</span></div><div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">先贴一张图</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194858641-1101400086.png" alt="" data-attr-org-src-id="877EF9AC56904A97A0C89F03D9C82A23" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="background-color: rgba(255, 255, 255, 1); font-style: italic; color: rgba(26, 26, 26, 1); font-size: 15px">持续集成(Continuous Integration)</span></div>
<ul>
<li style="list-style-position: inside; text-align: left; line-height: 1.75; list-style-type: disc; font-style: normal; font-family: "Microsoft YaHei", STXihei; white-space: pre-wrap; color: rgba(26, 26, 26, 1); font-size: 15px; font-weight: normal"><span style="background-color: rgba(255, 255, 255, 1); color: rgba(26, 26, 26, 1); font-size: 15px">持续集成强调开发人员提交了新代码之后,立刻进行构建、(单元)测试(这个要看情况了是否需要)</span></li>
</ul>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="background-color: rgba(255, 255, 255, 1); font-style: italic; color: rgba(26, 26, 26, 1); font-size: 15px">持续交付(Continuous Delivery)</span></div>
<ul>
<li style="list-style-position: inside; text-align: left; line-height: 1.75; list-style-type: disc; font-style: normal; font-family: "Microsoft YaHei", STXihei; white-space: pre-wrap; color: rgba(0, 0, 0, 1); font-size: 14px; font-weight: normal">持续交付在持续集成的基础上,将集成后的代码部署到更贴近真实运行环境的「类生产环境」(<span style="font-style: italic">production-like environments</span>)中。比如,我们完成单元测试后,可以把代码部署到连接数据库的 Staging 环境中更多的测试。如果代码没有问题,可以继续<span style="text-decoration: underline">手动部署</span>到生产环境中。</li>
</ul>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="background-color: rgba(255, 255, 255, 1); font-style: italic; color: rgba(26, 26, 26, 1); font-size: 15px">持续部署(Continuous Deployment)</span></div>
<ul>
<li style="list-style-position: inside; text-align: left; line-height: 1.75; list-style-type: disc; font-style: normal; font-family: "Microsoft YaHei", STXihei; white-space: pre-wrap; color: rgba(26, 26, 26, 1); font-size: 15px; font-weight: normal"><span style="background-color: rgba(255, 255, 255, 1); color: rgba(26, 26, 26, 1); font-size: 15px">持续部署则是在持续交付的基础上,把部署到生产环境的过程自动化。</span></li>
</ul>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="background-color: rgba(255, 255, 255, 1); color: rgba(26, 26, 26, 1); font-size: 15px">更多概念请参考</span><span style="background-color: rgba(255, 255, 255, 1); color: rgba(0, 56, 132, 1); font-size: 15px; text-decoration: underline">https://link.zhihu.com/?target=http%3A//www.mindtheproduct.com/2016/02/what-the-hell-are-ci-cd-and-devops-a-cheatsheet-for-the-rest-of-us/</span></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div id="3515-1526370150668" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="font-size: 32px; font-weight: bold">减少重复劳动 提高效率</span></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">jenkins大家都知道吧,但今天我们用微软的vsts来定制个性化定制持续集成交付(个人或者小团队我建议用vsts 也不用自己安装jenkins环境了 直接用vsts在线系统很方便)</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">用到的资源有:</div>
<ol>
<li style="list-style-position: inside; text-align: left; line-height: 1.75; list-style-type: decimal; font-style: normal; font-family: "Microsoft YaHei", STXihei; white-space: pre-wrap; color: rgba(0, 0, 0, 1); font-size: 14px; font-weight: normal">腾讯云服务器ubuntu一台(自己先安装好docker哈)</li>
<li style="list-style-position: inside; text-align: left; line-height: 1.75; list-style-type: decimal; font-style: normal; font-family: "Microsoft YaHei", STXihei; white-space: pre-wrap; color: rgba(0, 0, 0, 1); font-size: 14px; font-weight: normal">vsts创建一个git(有微软账号就能免费创建,<=5人团队是免费使用的,对于敏捷团队绰绰有余啦) <span style="color: rgba(0, 56, 132, 1); text-decoration: underline">https://www.visualstudio.com/zh-hans/team-services/</span></li>
</ol>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">一步步看图</div>
<div id="7098-1526383227987" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="color: rgba(89, 89, 89, 1); font-size: 18px; font-weight: bold">第一步 在vsts创建一个工程</span></div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194912620-1944809890.png" alt="" data-attr-org-src-id="E9D23AA1F6804568BF3F06845058C6DB" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194915875-136119065.png" alt="" data-attr-org-src-id="2C3BAFD686C94CA6BAC0F31FD1EC14F7" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194919042-1850032768.png" alt="" data-attr-org-src-id="E4431ADBEE0E40BBA13104DEC01EA2A3" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194922288-1641157919.png" alt="" data-attr-org-src-id="E9395C4BEE2D426E823DFB13A86C8182" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">创建git用户</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194925454-1154416545.png" alt="" data-attr-org-src-id="800B6D32D6B04BB09CC9D1E43D5FBFA0" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">然后用git工具clone到本地 我习惯用Sourcetree 大家可以用自己习惯的方式</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">如果提示输入密码就输入上面创建的用户名和密码</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194928608-1823747255.png" alt="" data-attr-org-src-id="0112AB0D15E046A0B2C89A3012371AF8" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div id="7038-1526383247923" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="color: rgba(89, 89, 89, 1); font-size: 18px; font-weight: bold">第二步创建一个实验工程</span></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">这里我们创建一个非常简单的console webapplication</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194931870-496177007.png" alt="" data-attr-org-src-id="C125DCB63F80412A85A4166F9D20AD74" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">安装nuget包</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194934997-88106078.png" alt="" data-attr-org-src-id="3A117CA70A3C4605B7741D2BA80090C4" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194938116-207289788.png" alt="" data-attr-org-src-id="FCB53D5C57BE4D16A7D6349BC2AA6596" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div><img alt="" data-attr-org-src-id="4C47D3CDA7E547998DCE81B6084BBE22" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">这里注意一点:我这里写死了 用 5001端口 注意我用的是 *:5001 没有用 localhost:5001 如果用这个方式的话 部署docker上会访问不了</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194944333-32472973.png" alt="" data-attr-org-src-id="29CC2F2FD3A94D13A4F8EE910DFC53FF" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">确认可以跑起来</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194947536-1506104396.png" alt="" data-attr-org-src-id="892F8CC842D54D419D18D5D50E263322" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">然后git提交代码到master分支</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div id="1430-1526373296421" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="color: rgba(89, 89, 89, 1); font-size: 18px; font-weight: bold">第三步我们来配置vsts</span></div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194950770-1994390178.png" alt="" data-attr-org-src-id="D2A571A473784ADE9798739B479936D5" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">先配置第一部分 一有代码提交到master分支 就自动编译 打包 【CI部分】</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194953999-172535538.png" alt="" data-attr-org-src-id="FFCDF46A1C334F07916A3DAF41D3A717" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515194957131-1813171661.png" alt="" data-attr-org-src-id="95DD7D24364941E8A447BCE0A5187FEF" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">选择 ASP.NET Core 会默认有以下Task</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195000304-569583079.png" alt="" data-attr-org-src-id="D1876BBF2E634DABA8B63F7658B1B352" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">一定要注意选择linux环境编译</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195003549-865473891.png" alt="" data-attr-org-src-id="FAE4F2101C934711AA8A4AC94AB9BD2A" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">Test我们暂时不需要就Remove掉</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">由于我们不是web project</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195006804-804372562.png" alt="" data-attr-org-src-id="4F912FBAA261418B919EEC13B75C240C" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">配置触发器 (意思就是一有代码提交打master分支[可以指定特定分支]就会触发CI)</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195010003-1000424454.png" alt="" data-attr-org-src-id="158834191A594489859E00D94A450B6C" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">尝试跑一下</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195013181-1211666813.png" alt="" data-attr-org-src-id="351BA1A88C2449FAA4A0B557E6504306" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195016313-583271687.png" alt="" data-attr-org-src-id="88D8C190D0C04BB6856DA365C8D09DB7" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">CI正常完成</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195019635-989132875.png" alt="" data-attr-org-src-id="8178D2528C9C46F6A03811E0EDF19DEC" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">到此CI配置工作已完成</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">接下来我想要完成自动 发布到我的腾讯云服务器 在服务器上把发布的文件打包并生成一个image 然后用这个image生成一个Container 并启动</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div id="1369-1526374567506" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="color: rgba(89, 89, 89, 1); font-size: 18px; font-weight: bold">第四部我们配置Release</span></div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195022763-896446546.png" alt="" data-attr-org-src-id="D761955D93A047EAB5E9B9B79A593776" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195025928-1423578095.png" alt="" data-attr-org-src-id="389919B55A13494BBF76428F522EB7B3" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195029220-286763369.png" alt="" data-attr-org-src-id="98F20C6F2DEE43D4B7606F6FA176D300" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">Sourece alias 这个大家可以修改成名字短一点</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">执行Release发布的时候会把之前CI public的东西download然后放在命名为 Source alisa文件夹内</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">我改成 _test_netcore-docker</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195032514-147289123.png" alt="" data-attr-org-src-id="E9A78862233A482FAF64C65A710530C3" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">接下来来配置环境</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">大家可以根据实际情况配置多个环境 比如 集成测试环境 和 prod环境</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">我这里就只配置一个prod环境</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195035832-649762660.png" alt="" data-attr-org-src-id="441D3741FFA8456CBBAD5FE10F4C2BE8" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">由于我们是发布到腾讯云服务器 所以在这里选择 Empt process 且命名为prod</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195039061-1257376143.png" alt="" data-attr-org-src-id="CB599DB1FF84435EBA453AD658F47F00" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">接下来要配置 Release 操作的 Task</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195042260-783195512.png" alt="" data-attr-org-src-id="AB4D2B38B8144B56952E17676C947B41" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">我们添加SSH 目的是用SSH 链接到 腾讯云服务器 然后 把发布的文件通过SSH传输到我的服务器</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195045570-596218276.png" alt="" data-attr-org-src-id="698129EFB8BA47B7A42D27C391C11981" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">得先配置SSH无密码登录</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195048865-1100096097.png" alt="" data-attr-org-src-id="0FD2D07A99E54A95ADE0AB639BB03742" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195052025-1332231142.png" alt="" data-attr-org-src-id="8FFF64800E334E2FA24B896FAF820460" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">按照提示进行配置</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195055230-574541968.png" alt="" data-attr-org-src-id="22D077986AD7453480C753A2F8A79CBE" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">配置好后</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195602986-863495318.png" alt="">
<p> </p>
</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">Source folder 输入我们之前配置的别名 _test_netcore-docker</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">最终如下</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195111960-1772739373.png" alt="" data-attr-org-src-id="3E447701C54247B181D792117CC17E63" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">然后再添加SSH执行命令工具</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195115271-1345044971.png" alt="" data-attr-org-src-id="FFB0525FC7734667B8F7E0C386D59A20" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195118616-1030469406.png" alt="" data-attr-org-src-id="B9B19559D22449A6BCF2BE233C80B327" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">unzip -q site/drop/<span style="background-color: rgba(255, 255, 255, 1); color: rgba(36, 41, 46, 1)">TestDotnetcore</span>.zip -d site/drop/ 发布的文件是zip的 通过这个命令解压zip <<span style="background-color: rgba(255, 255, 255, 1); color: rgba(36, 41, 46, 1)">TestDotnetcore.zip是我查看发布的日志找到的这个名字目前我还没有找到变量可以代替</span>></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">sudo rm -rf site/drop/*.zip 解压完成后删除掉</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">touch site/drop/Dockerfile 生成一个dockerfile</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">echo "FROM microsoft/aspnetcore:2.0" >> site/drop/Dockerfile echo命令是往创建的dockerfile里面写入内容</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">echo "COPY . /publish" >> site/drop/Dockerfile</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">echo "WORKDIR /publish" >> site/drop/Dockerfile</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">echo "EXPOSE 5001" >> site/drop/Dockerfile</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">echo "CMD [\"dotnet\", \"TestDotnetcore.dll\"]" >> site/drop/Dockerfile</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">sudo docker build --rm -t test_image -f site/drop/Dockerfile site/drop/ 创建一个image 名字叫 test_image</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">sudo docker ps -q --filter "name=test_netcore" | grep -q . && sudo docker rm -f test_netcore || true 查看是否有没有叫 test_netcore的容器有没有在runing 如果有就干掉它</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">sudo docker run --name test_netcore -d -p 5001:5001 test_image:latest 根据test_image启动一个名字叫test_netcore的容器</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="text-decoration: line-through">if sudo docker images -f "dangling=true" | grep ago --quiet; then sudo docker rmi -f $(sudo docker images -f "dangling=true" -q); fi</span> 查看是否有<none>的image 把它删掉 因为我们创建image的时候每次都会覆盖所以会产生一些没有的image</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">sudo docker images -f "dangling=true" | grep -q . && sudo docker rmi -f $(sudo docker images -f "dangling=true" -q)</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">sudo rm -rf site/drop 都ok了就删掉drop目录</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div id="7075-1526378128829" style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="font-size: 32px; font-weight: bold">以上一切准备好 提交一个commit到master试试</span></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="font-weight: bold; text-decoration: underline">会自动触发CI 进行 编译 发布</span></div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195121957-1162804331.png" alt="" data-attr-org-src-id="73DD1A53E8E444F7820CD1DB8826DA3E" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="font-weight: bold; text-decoration: underline">接下来Release发布</span></div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195125148-364316163.png" alt="" data-attr-org-src-id="4B41797C4C8847E58719E357612EDC1D" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">发布打包的成果物在这里查看</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195128283-1967423586.png" alt="" data-attr-org-src-id="8BAAD655F95B4E39956D42CA80957CBF" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195131528-1068323004.png" alt="" data-attr-org-src-id="E5355EC2CEBE4ACBB73E0F14FDF56F7C" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195135015-1378217323.png" alt="" data-attr-org-src-id="33F00B74990E4B7880735740B83F6EC0" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">发布成功 查看下docker image</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195138202-466030448.png" alt="" data-attr-org-src-id="90E4C2F393994795BB5F5CD35C3F0099" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">已经成功创建了test_image这个镜像</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">容器是也跑成功了</div>
<div style="text-align: left; float: none"><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195141303-1479838888.png" alt="" data-attr-org-src-id="899A8644B2854431BB3BCC26EEB112D8" data-media-type="image"></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">验证一下</div>
<div><img src="https://images2018.cnblogs.com/blog/472365/201805/472365-20180515195245031-890718534.png" alt="">
<p> </p>
</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">完美!!!不管你用的是腾讯云还是阿里云还是其他云都是可以的!</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"> </div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px">遗留问题:</div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="background-color: rgba(255, 255, 255, 1); color: rgba(36, 41, 46, 1)">TestDotnetcore.zip是我查看发布的日志找到的这个名字目前我还没有找到变量可以代替</span></div>
<div style="text-align: left; line-height: 1.75; white-space: pre-wrap; font-size: 14px"><span style="background-color: rgba(255, 255, 255, 1); color: rgba(36, 41, 46, 1)">有谁知道帮忙教育下!</span></div>
<p> </p>
</div>
<div id="MySignature" role="contentinfo">
<hr>
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,转载文章之后须在文章页面明显位置给出作者和原文连接,谢谢。<br><br>
来源:https://www.cnblogs.com/yudongdong/p/9042750.html
頁:
[1]