{"id":4865,"date":"2021-06-19T14:35:03","date_gmt":"2021-06-19T06:35:03","guid":{"rendered":"https:\/\/dmesg.app\/?p=4865"},"modified":"2021-06-19T14:46:57","modified_gmt":"2021-06-19T06:46:57","slug":"dockerhub-submodule","status":"publish","type":"post","link":"https:\/\/dmesg.app\/dockerhub-submodule.html","title":{"rendered":"Docker Hub\u4e0esubmodule\u8e29\u5751\u5c0f\u8bb0"},"content":{"rendered":"<p><span style=\"font-size: 12pt;\">\u5927\u5bb6\u90fd\u61c2\uff0c\u4f7f\u7528 Docker\u5206\u53d1\u5e94\u7528\u662f\u975e\u5e38\u8212\u670d\u7545\u5feb\u7684\u4e8b\u60c5\uff01\u901a\u5e38\u6765\u8bf4\uff0c\u5982\u679c\u6211\u4eec\u5728GitHub\u5f00\u6e90\u4ee3\u7801\uff0c\u901a\u5e38\u4e5f\u5c31\u4f1a\u9009\u62e9Docker Hub\u6765\u6784\u5efa\u955c\u50cf\u3002\u5f53\u7136\u5566\uff0c\u7528GitHub Action\uff0c\u6216\u8005\u81ea\u5df1\u6784\u5efa\u518d\u63d0\u4ea4\u4e5f\u662f\u4e00\u79cd\u529e\u6cd5\u54e6\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u600e\u4e48\u5199Dockerfile\uff0c\u6bd4\u5982\u4e0d\u540c\u5c42\u7ea7\u7684RUN\uff0c\u6b63\u786e\u5e94\u7528multi stage build\uff0c\u90a3\u662f\u53e6\u5916\u4e00\u4e2a\u8bdd\u9898\u5566\u3002\u4eca\u5929\u6765\u8bf4\u8bf4\u5728\u4e3a yyetsweb\u6784\u5efadocker image\u7684\u65f6\u5019\uff0c\u6211\u8e29\u5230\u7684\u5751\u2026\u2026<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u73af\u5883\u53d8\u91cf<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u8bf4\u5230\u73af\u5883\u53d8\u91cf\uff0c\u9996\u5148\u6211\u4eec\u8981\u533a\u5206\u4e00\u4e0b\u8fd0\u884c\u65f6\u73af\u5883\u53d8\u91cf\u548c\u6784\u5efa\u65f6\u73af\u5883\u53d8\u91cf\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">\u8fd0\u884c\u65f6\u73af\u5883\u53d8\u91cf<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u6211\u4eec\u5728Dockerfile\u4e2d\u4f7f\u7528 <code>ENV<\/code>\u5b9a\u4e49\u7684\u53d8\u91cf\u5c31\u53ef\u4ee5\u7b97\u8fd0\u884c\u65f6\u73af\u5883\u53d8\u91cf\u5566\uff0c\u6bd4\u5982\u8bf4\u8fd9\u6837\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">ENV TZ=Asia\/Shanghai\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u8fd9\u4e2a<code>TZ<\/code>\u53d8\u91cf\u4f1a\u88ab\u5bb9\u5668\u4e2d\u7684\u7a0b\u5e8f\u76f4\u63a5\u8bfb\u53d6\u4f7f\u7528\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">\u6784\u5efa\u65f6\u73af\u5883\u53d8\u91cf<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u5728\u6784\u5efa\u65f6\u4f1a\u88ab\u8bfb\u53d6\u4f7f\u7528\u7684\u53d8\u91cf\uff0c\u6bd4\u5982\u8bf4\u5728Docker Hub\u4f1a\u6709\u8fd9\u6837\u7684\u8bbe\u7f6e\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2021\/06\/2021061914224777.png\" alt=\"Docker Hub\u4e0esubmodule\u8e29\u5751\u5c0f\u8bb0\" title=\"Docker Hub\u4e0esubmodule\u8e29\u5751\u5c0f\u8bb0\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u90a3\u4e48\u8fd9\u4e2a\u53d8\u91cf\u5c31\u662f\u53ef\u4ee5\u5728Dockerfile\u91cc\u4f7f\u7528\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">RUN echo $REACT_APP_DOMAIN\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u4f7f\u7528\u7684\u5566\u3002<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u6211\u7684\u4f7f\u7528<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u56e0\u4e3a\u524d\u7aef\u7684SPA\u5e94\u7528\u8981\u5728\u6784\u5efa\u65f6\u4f7f\u7528\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\uff0c\u6240\u4ee5\u6211\u5c31\u5728 Docker Hub\u7684\u8bbe\u7f6e\u4e2d\u52a0\u4e86\u8fd9\u51e0\u4e2a\uff0c\u4f46\u662f\u4f3c\u4e4e\u5e76\u6ca1\u6709\u751f\u6548\u3002\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\uff0c\u8003\u8651\u5230\u6784\u5efa\u65f6\u4f1a\u8bfb\u53d6\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684<code> .env<\/code>\u6587\u4ef6\uff0c\u90a3\u4e0d\u5982\u5e94\u7528\u4e00\u4e0bDocker Hub\u7684hooks\u5427\uff01<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">Docker Hub\u7684build hooks\u4e00\u5171\u6709\u8fd9\u4e48\u51e0\u79cd\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 12pt;\">hooks\/post_checkout<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">hooks\/pre_build<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">hooks\/post_build<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">hooks\/pre_test<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">hooks\/post_test<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">hooks\/pre_push (only used when executing a build rule or automated build )<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">hooks\/post_push (only used when executing a build rule or automated build )<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12pt;\">\u6bcf\u4e00\u4e2ahook\u90fd\u53ef\u4ee5\u5305\u542bdocker\u547d\u4ee4\u548c\u5404\u79cdbash\u547d\u4ee4\u3002\u90a3\u5bf9\u4e8e\u6211\u7684\u573a\u666f\u6765\u8bf4\uff0c \u521b\u5efa\u4e00\u4e2a<code>pre_build<\/code>\u5c31\u53ef\u4ee5\u5566<\/span><\/p>\n<pre class=\"prettyprint linenums\">#!\/bin\/bash\r\ncat &lt;&lt; EOF &gt;&gt; YYeTsFE\/.env\r\nSENTRY_ORG=$SENTRY_ORG\r\nSENTRY_PROJECT=$SENTRY_PROJECT\r\nSENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN\r\n\r\nREACT_APP_SENTRY_DSN=$REACT_APP_SENTRY_DSN\r\nREACT_APP_DOMAIN=$REACT_APP_DOMAIN\r\nREACT_APP_GA=$REACT_APP_GA\r\n# sourcemap\r\nGENERATE_SOURCEMAP=$GENERATE_SOURCEMAP\r\nEOF\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u5b8c\u7f8e\uff01<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">submodule<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u4f7f\u7528git submodule\u7ee7\u627f\u5176\u4ed6\u9879\u76ee\u662f\u975e\u5e38\u7406\u60f3\u7684\u4e00\u79cd\u5f00\u53d1\u65b9\u5f0f\u3002\u6211\u4eec\u53ef\u4ee5\u63a7\u5236submodule\u8ddf\u8e2a\u5230\u4e0a\u6e38\u7684\u54ea\u4e00\u4e2acommit\uff0c\u9700\u8981\u66f4\u65b0\u65f6\u53ea\u9700\u8981\u4e00\u4e2a<code> git submodule update --remote<\/code>\uff0c\u7136\u540e\u518d\u628ahash commit\u5c31\u53ef\u4ee5\u5566\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">Docker Hub\u5728build\u65f6\u4f1a\u81ea\u52a8clone\u76f8\u5e94\u7684submodule\uff0c\u56e0\u6b64\u5e38\u89c4\u60c5\u51b5\u4e0b\u6765\u8bb2\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u90fd\u662f\u53ef\u4ee5\u987a\u5229\u6784\u5efa\u7684\u3002\u53ea\u4e0d\u8fc7\u6709\u51e0\u70b9\u9700\u8981\u6ce8\u610f\uff1a<\/span><\/p>\n<ol>\n<li><span style=\"font-size: 12pt;\">docker hub\u6267\u884c\u7684\u662fshallow copy\uff0c\u56e0\u6b64\u53ea\u6709\u6700\u65b0\u7684commit\u548c\u5bf9\u5e94\u7684branch\u4f1a\u88ab\u62c9\u4e0b\u6765\uff0c\u56e0\u6b64\u5982\u679c\u4f60\u7684build\u811a\u672c\u662f\u4f9d\u8d56\u4e86git branch\u548c\u4e0d\u540c\u7684commit\uff0c\u90a3\u4f1a\u5931\u8d25\u7684\u54e6\u3002\u8fd9\u4e2a\u65f6\u5019\u8981\u7528hooks\u6765\u89e3\u51b3<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">private submodule\u9700\u8981\u4e00\u4e9b\u989d\u5916\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u53c2\u8003\u5b98\u7f51\u6587\u6863\u6765\u89e3\u51b3<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">\u5728module\u91cc\u6267\u884cgit\u76f8\u5173\u7684\u547d\u4ee4\uff0c\u5f88\u6709\u53ef\u80fd\u5931\u8d25\u7684\u54e6\uff08\u8fd9\u53ef\u80fd\u662fDocker Hub\u7684bug\uff0c\u4e5f\u6709\u53ef\u80fd\u662fgit\u7248\u672c\u7684\u95ee\u9898\uff09\u3002<\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: 12pt;\">\u6211\u8981\u8be6\u7ec6\u7684\u8bf4\u4e0b\u7b2c\u4e09\u70b9\ud83e\udd23<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5728\u6211\u7684\u6784\u5efa\u811a\u672c\u4e2d\uff0c\u6211\u7528\u4e86<code>git rev-parse --short HEAD<\/code> \u6765\u83b7\u53d6submodule\u7684hash\uff0c\u7136\u540e\u628a\u8fd9\u4e2ahash\u4f5c\u4e3atag\u63a8\u9001\u5230sentry\u4e0a\u3002\u4f46\u662f\u5728\u6784\u5efa\u65e5\u5fd7\u4e2d\u53d1\u73b0\u4e86\u8fd9\u79cd\u9519\u8bef\uff1a<\/span><\/p>\n<pre class=\"prettyprint\" >---&gt; Running in 4c09a0ea3725\r\n\r\nyarn run v1.22.5\r\n\r\n$ (export REACT_APP_SENTRY_RELEASE=$(git rev-parse --short HEAD); react-scripts build &amp;&amp; node scripts\/sentry.js)\r\n\r\n[91mfatal: not a git repository: \/src\/bt57w8kzzcjnpmscaemsqqq\/.git\/modules\/YYeTsFE<\/pre>\n<p>\u7136\u800c\u5728\u672c\u5730\u5b8c\u5168\u662f\u65e0\u6cd5\u590d\u73b0\u7684\uff0c\u6574\u4e2a\u76ee\u5f55\u6811\u5982\u4e0b\uff0c\u6211\u4fdd\u8bc1Docker Hub\u5728build\u65f6\u4e5f\u6709\u540c\u6837\u7684\u7ed3\u6784\uff1a<\/p>\n<pre class=\"prettyprint\" >$ tree -L 2 -a\r\n\r\n|-- .dockerignore\r\n|-- .git\r\n| |-- HEAD\r\n| |-- branches\r\n| |-- config\r\n| |-- description\r\n| |-- hooks\r\n| |-- index\r\n| |-- info\r\n| |-- logs\r\n| |-- modules\r\n| |-- objects\r\n| |-- packed-refs\r\n| `-- refs\r\n|-- .gitattributes\r\n|-- .gitignore\r\n|-- .gitmodules\r\n|-- .travis.yml\r\n|-- Dockerfile\r\n|-- Makefile\r\n|-- README.md\r\n|-- YYeTsFE\r\n| |-- .env.example\r\n| |-- .git\r\n| |-- .gitignore\r\n| |-- .sentryclirc\r\n| |-- README.md\r\n| |-- package.json\r\n| |-- public\r\n| |-- scripts\r\n| |-- src\r\n| |-- tsconfig.json\r\n| `-- yarn.lock\r\n\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">submodule\u4e5f\u6709.git\uff0c\u9879\u76ee\u6839\u76ee\u5f55\u4e5f\u6709.git\uff0c\u4e3a\u4ec0\u4e48\u5c31\u4f1a\u5931\u8d25\u5462\uff1f\u8fdb\u884c\u4e86\u65e0\u6570\u6b21\u5c1d\u8bd5\uff0c\u8ba9Docker Hub\u4e00\u665a\u4e0a\u75af\u72c2\u6784\u5efa\ud83d\ude02<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u540e\u6765\u7814\u7a76\u4e86\u4e00\u4e0b\uff0csubmodule\u7684.git\u5176\u5b9e\u662f\u4e00\u4e2a\u5230\u7236\u76ee\u5f55<code>.git\/modules\/ModuleName<\/code>\u7684\u5f15\u7528\u3002<\/span><\/p>\n<pre class=\"prettyprint linenums\">~\/PycharmProjects\/YYeTsBot\/YYeTsFE (60c497b*) [02:06:51]\r\nbenny$ cat .git\r\ngitdir: ..\/.git\/modules\/YYeTsFE\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u7136\u800c\u5728 Docker Hub\u4e0a\uff0c\u8fd9\u4e2a\u76ee\u5f55\u662f\u7edd\u5bf9\u8def\u5f84\uff0c\u5e76\u4e14\u662fhost\u7684\u8def\u5f84\ud83e\udd26\u200d\u2642\ufe0f\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">gitdir: \/src\/brp47ykf7wlmztspk2mtpl8\/.git\/modules\/YYeTsFE\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u8fd9\u4e0d\u62a5\u9519\u5c31\u602a\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u89e3\u51b3\u65b9\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u5728hook\u4e2d\u6539\u6389<code>.git<\/code>\u6587\u4ef6\uff0c\u6216\u8005\u5728Dockerfile\u4e2d\u6539\u6389\uff0c\u8003\u8651\u5230\u65e0\u6cd5\u5b9a\u4f4d\u5230\u95ee\u9898\u7a76\u7adf\u662f\u51fa\u5728Docker Hub\u8fd8\u662fgit\uff0c\u6211\u5c31\u9009\u62e9\u5728Dockerfile\u4e2d\u641e\u5566<\/span><\/p>\n<pre class=\"prettyprint linenums\">RUN echo &quot;gitdir: ..\/.git\/modules\/YYeTsFE&quot; &gt; .git\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u5c31\u8fd9\u4e48\u4e00\u884c\u4ee3\u7801\uff0c\u82b1\u4e86\u6211\u4e24\u4e09\u4e2a\u5c0f\u65f6\ud83c\udf1a\ud83c\udf1a\ud83e\udd2c<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u53c2\u8003<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">Docker Hub build hooks: <a href=\"https:\/\/docs.docker.com\/docker-hub\/builds\/advanced\/\">https:\/\/docs.docker.com\/docker-hub\/builds\/advanced\/<\/a><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">YYeTsBot: <a href=\"https:\/\/github.com\/tgbot-collection\/YYeTsBot\">https:\/\/github.com\/tgbot-collection\/YYeTsBot<\/a><\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u90fd\u61c2\uff0c\u4f7f\u7528 Docker\u5206\u53d1\u5e94\u7528\u662f\u975e\u5e38\u8212\u670d\u7545\u5feb\u7684\u4e8b\u60c5\uff01\u901a\u5e38\u6765\u8bf4\uff0c\u5982\u679c\u6211\u4eec\u5728GitHub\u5f00\u6e90\u4ee3\u7801\uff0c\u901a\u5e38\u4e5f\u5c31\u4f1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-4865","post","type-post","status-publish","format-standard","hentry","category-program"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/4865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/comments?post=4865"}],"version-history":[{"count":3,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/4865\/revisions"}],"predecessor-version":[{"id":4869,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/4865\/revisions\/4869"}],"wp:attachment":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/media?parent=4865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/categories?post=4865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/tags?post=4865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}