{"id":206131,"date":"2025-06-12T12:22:48","date_gmt":"2025-06-12T04:22:48","guid":{"rendered":"https:\/\/server.hk\/cnblog\/206131\/"},"modified":"2025-06-12T12:22:48","modified_gmt":"2025-06-12T04:22:48","slug":"micro-%e5%be%ae%e6%9c%8d%e5%8a%a1%e6%a1%86%e6%9e%b6-dockerfile-%e4%b8%ad%e7%9a%84-helloworld-srv-%e6%96%87%e4%bb%b6%e5%9c%a8%e5%93%aa%e9%87%8c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/206131\/","title":{"rendered":"Micro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f"},"content":{"rendered":"<p>\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aMicro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f\u300b<\/span>\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~,<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241104\/173070203667286ad48b859.jpg\" class=\"aligncenter\">,<br \/>\n<strong>micro \u5fae\u670d\u52a1\u6846\u67b6 dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u7591\u95ee<\/strong>,\u5728\u4f7f\u7528 micro \u5fae\u670d\u52a1\u6846\u67b6\u65f6\uff0c\u4f60\u9047\u5230\u4e86 dockerfile \u4e2d\u5305\u542b\u7684 helloworld-srv \u6587\u4ef6\u7684\u56f0\u60d1\uff0c\u8be5\u6587\u4ef6\u5728\u4f60\u7684\u73af\u5883\u4e2d\u4f3c\u4e4e\u4e0d\u5b58\u5728\u3002,<br \/>\n<strong>\u95ee\u9898\u91ca\u7591<\/strong>,\u5982\u7b54\u6848\u6240\u8ff0\uff0chelloworld-srv \u662f\u5728\u5e94\u7528\u7f16\u8bd1\u65f6\u751f\u6210\u7684\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u627f\u8f7d\u5e94\u7528\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u4f60\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a,\u5728\u6b64\u60c5\u51b5\u4e0b\uff0c\u4f60\u9700\u8981\u9996\u5148\u7f16\u8bd1\u4f60\u7684\u5e94\u7528\u624d\u80fd\u83b7\u5f97 helloworld-srv \u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u7f16\u8bd1\u5e94\u7528\uff1a,\u7136\u540e\uff0c\u5c06\u751f\u6210\u7684 helloworld-srv \u6587\u4ef6\u590d\u5236\u5230 dockerfile \u4e2d\u6307\u5b9a\u7684\u76ee\u5f55\uff08\u901a\u5e38\u4e3a \/app\uff09\u3002\u4fee\u6539\u540e\u7684 dockerfile \u53ef\u80fd\u5982\u4e0b\u6240\u793a\uff1a,\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u6784\u5efa docker \u955c\u50cf\u5e76\u8fd0\u884c\u5bb9\u5668\uff0c\u4f60\u7684\u5e94\u7528\u5c06\u5f00\u59cb\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u3002,\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aMicro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01,\u5c06\u751f\u6210\u7684 helloworld-srv \u590d\u5236\u5230 dockerfile \u6307\u5b9a\u7684\u76ee\u5f55\u4e2d\u3002,\u7f16\u8bd1\u4f60\u7684\u5e94\u7528\uff0c\u8fd9\u4f1a\u751f\u6210 helloworld-srv \u4e8c\u8fdb\u5236\u6587\u4ef6\u3002,\u6784\u5efa docker \u955c\u50cf\uff0c\u4ee5\u4fbf\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u5e94\u7528\u3002,micro \u5fae\u670d\u52a1\u6846\u67b6 dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u7591\u95ee,\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aMicro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f\u300b<\/span>\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~,<br \/>\n<b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>Micro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f<\/span><\/p>\n<h1>Micro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f<\/h1>\n<p><span>2024-11-04 14:34:12<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aMicro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f\u300b<\/span>\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241104\/173070203667286ad48b859.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>micro \u5fae\u670d\u52a1\u6846\u67b6 dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u7591\u95ee<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 micro \u5fae\u670d\u52a1\u6846\u67b6\u65f6\uff0c\u4f60\u9047\u5230\u4e86 dockerfile \u4e2d\u5305\u542b\u7684 helloworld-srv \u6587\u4ef6\u7684\u56f0\u60d1\uff0c\u8be5\u6587\u4ef6\u5728\u4f60\u7684\u73af\u5883\u4e2d\u4f3c\u4e4e\u4e0d\u5b58\u5728\u3002<\/p>\n<p><strong>\u95ee\u9898\u91ca\u7591<\/strong><\/p>\n<p>\u5982\u7b54\u6848\u6240\u8ff0\uff0chelloworld-srv \u662f\u5728\u5e94\u7528\u7f16\u8bd1\u65f6\u751f\u6210\u7684\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u627f\u8f7d\u5e94\u7528\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u4f60\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li>\u7f16\u8bd1\u4f60\u7684\u5e94\u7528\uff0c\u8fd9\u4f1a\u751f\u6210 helloworld-srv \u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/li>\n<li>\u5c06\u751f\u6210\u7684 helloworld-srv \u590d\u5236\u5230 dockerfile \u6307\u5b9a\u7684\u76ee\u5f55\u4e2d\u3002<\/li>\n<li>\u6784\u5efa docker \u955c\u50cf\uff0c\u4ee5\u4fbf\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u5e94\u7528\u3002<\/li>\n<\/ul>\n<p>\u5728\u6b64\u60c5\u51b5\u4e0b\uff0c\u4f60\u9700\u8981\u9996\u5148\u7f16\u8bd1\u4f60\u7684\u5e94\u7528\u624d\u80fd\u83b7\u5f97 helloworld-srv \u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u7f16\u8bd1\u5e94\u7528\uff1a<\/p>\n<pre>go build -o helloworld-srv<\/pre>\n<p>\u7136\u540e\uff0c\u5c06\u751f\u6210\u7684 helloworld-srv \u6587\u4ef6\u590d\u5236\u5230 dockerfile \u4e2d\u6307\u5b9a\u7684\u76ee\u5f55\uff08\u901a\u5e38\u4e3a \/app\uff09\u3002\u4fee\u6539\u540e\u7684 dockerfile \u53ef\u80fd\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>FROM golang:1.15\n\nWORKDIR \/app\n\nCOPY helloworld-srv .\n\nCMD [\"\/app\/helloworld-srv\"]<\/pre>\n<p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u6784\u5efa docker \u955c\u50cf\u5e76\u8fd0\u884c\u5bb9\u5668\uff0c\u4f60\u7684\u5e94\u7528\u5c06\u5f00\u59cb\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aMicro \u5fae\u670d\u52a1\u6846\u67b6 Dockerfile \u4e2d\u7684 helloworld-srv \u6587\u4ef6\u5728\u54ea\u91cc\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   Sequelize \u9ed8\u8ba4\u65f6\u95f4\u751f\u6210\u4e0d\u51c6\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u4e3a\u4ec0\u4e48\u8bbe\u7f6e body \u5143\u7d20 flex \u5e03\u5c40\u540e\u5b50\u5143\u7d20\u65e0\u6cd5\u5782\u76f4\u5c45\u4e2d\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9 GOLA&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-206131","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=206131"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206131\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=206131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=206131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=206131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}