{"id":10008268,"date":"2023-09-12T04:44:25","date_gmt":"2023-09-11T20:44:25","guid":{"rendered":"https:\/\/blog.itmax.cn\/?p=10008268"},"modified":"2023-09-12T04:44:25","modified_gmt":"2023-09-11T20:44:25","slug":"%e7%bb%99-python-%e7%9a%84%e7%88%ac%e8%99%ab-docker-%e9%95%9c%e5%83%8f%e6%b7%bb%e5%8a%a0-nodejs-%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10008268","title":{"rendered":"\u7ed9 python \u7684\u722c\u866b docker \u955c\u50cf\u6dfb\u52a0 nodejs \u73af\u5883"},"content":{"rendered":"<p>\u8fc7\u53bb\u4f1a\u4f7f\u7528\u7c7b\u4f3c <code>curl -sL https:\/\/deb.nodesource.com\/setup_16.x | bash -<\/code> \u8fd9\u6837\u7684\u65b9\u5f0f\u6dfb\u52a0 source \u6e90\uff0c\u7136\u540e\u5728\u4f7f\u7528 apt \u5b89\u88c5 nodejs<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2a\u65b9\u6cd5\u6700\u8fd1\u4e0d\u884c\u4e86\uff0c\u8fd0\u884c\u4f1a\u6709\u8b66\u544a<\/p>\n<pre><code class=\"shell\">root@f51e70203b5b:\/# curl -sL https:\/\/deb.nodesource.com\/setup_16.x | bash -\n\n================================================================================\n\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\n================================================================================\n\n                           SCRIPT DEPRECATION WARNING                    \n\n  \n  This script, located at https:\/\/deb.nodesource.com\/setup_X, used to\n  install Node.js is deprecated now and will eventually be made inactive.\n\n  Please visit the NodeSource distributions Github and follow the\n  instructions to migrate your repo.\n  https:\/\/github.com\/nodesource\/distributions\n\n  The NodeSource Node.js Linux distributions GitHub repository contains\n  information about which versions of Node.js and which Linux distributions\n  are supported and how to install it.\n  https:\/\/github.com\/nodesource\/distributions\n\n\n                          SCRIPT DEPRECATION WARNING\n\n================================================================================\n\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\n================================================================================\n\nTO AVOID THIS WAIT MIGRATE THE SCRIPT\nContinuing in 60 seconds (press Ctrl-C to abort) ...\n\n^C<\/code><\/pre>\n<p>\u5927\u6982\u610f\u601d\u5c31\u662f\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5df2\u7ecf out\u4e86\uff0cnodejs \u53eb\u4f60\u522b\u8fd9\u4e48\u7528\u4e86<\/p>\n<p>\u4ec0\u4e48 nodejs \u6700\u65b0\u63a8\u8350\u7684\u65b9\u5f0f\u662f\u4ec0\u4e48\u5462\uff1f<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=hmdYwLL%2FyvnzEQiZSLq9Hw%3D%3D.trZ3zbDtGR7EGSr3K1De6a6gkUj4RQOJ7nIr0HfraWLlp%2FuH75U%2FCK4jtuc1hTsgo41wDWM4qiek%2FOK8kIc0Ew%3D%3D\" rel=\"noopener noreferrer\">https:\/\/github.com\/nodesource\/distributions#debian-versions<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"455\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9Eha\" alt=\"\u56fe\u7247.png\" title=\"\u56fe\u7247.png\"><\/p>\n<p>\u9700\u8981\u66f4\u591a\u547d\u4ee4\u4e86\uff0c\u800c\u4e14\u5927\u5bb6\u77e5\u9053\uff0c\u56e0\u4e3a\u300c\u90aa\u6076\u957f\u57ce\u300d\u7684\u5b58\u5728\uff0c\u8fd9\u975e\u5e38\u4e0d\u9002\u5408\u5927\u9646\u5b9d\u5b9d<\/p>\n<p>\u4e0a\u9762\u7684\u65b9\u5f0f\u6709\u4e24\u4e2a\u7f3a\u70b9\uff1a<\/p>\n<ul>\n<li>\u7f51\u7edc\u95ee\u9898\uff0c\u4e0d\u9002\u5408\u5927\u9646\u5b9d\u5b9d<\/li>\n<li>\u53d8\u6765\u53d8\u53bb\uff0c\u65e9\u665a\u8981\u5403\u4e8f<\/li>\n<\/ul>\n<p>\u90a3\u4e48\u6709\u6ca1\u6709\u66f4\u52a0\u9002\u5408\u5927\u9646\u5b9d\u5b9d\u5e76\u4e14\u66f4\u52a0\u6c38\u6052\u4e0d\u53d8\u7684\u6253\u5305\u5b89\u88c5 nodejs \u65b9\u5f0f\u5462\uff1f<\/p>\n<p>\u5f53\u7136\u6709<\/p>\n<p>\u56e0\u4e3a python \u7684 docker \u955c\u50cf\u662f\u57fa\u4e8e debian \u6253\u5305\u7684<\/p>\n<p>debian \u7684\u4ed3\u5e93\u91cc\u9762\u5c31\u6709 nodejs<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"253\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9Ehs\" alt=\"\u56fe\u7247.png\" title=\"\u56fe\u7247.png\" loading=\"lazy\"><\/p>\n<p>\u4f46\u662f\u522b\u9009 buster \uff08debian10\uff09\uff0c\u56e0\u4e3a\u8fd9\u6b3e\u8fdc\u53e4\u65f6\u671f\u7684 debian 10 buster \u4ed3\u5e93\u91cc\u9762\u7684 nodejs \u662f 12 \u7248\u672c\u7684\uff0c\u72d7\u89c1\u4e86\u90fd\u6447\u5934<\/p>\n<p>\u5efa\u8bae\u9009\u62e9 bookworm \uff0c\u4e5f\u5c31\u662f debian12 \u7684\uff0c\u70ed\u4e4e\uff0c\u4eca\u5e74\u521a\u53d1\u5e03\u3002\u4ed3\u5e93\u91cc\u9762\u5e26\u7684 nodejs \u7248\u672c\u662f 18\uff0c\u5f88\u65b0\u9c9c<\/p>\n<p>\u4e0b\u9762\u662f Dockerfile \u793a\u4f8b<\/p>\n<pre><code class=\"Dockerfile\">FROM python:3.10.13-bookworm\n# \u6539\u53d8pip\u7f13\u5b58\u76ee\u5f55\n# RUN pip config set global.cache-dir \/pip\/cache\n# \u4f7f\u7528 aliyun \u5185\u7f51\u955c\u50cf\u6e90\n# RUN (echo &quot;deb http:\/\/mirrors.cloud.aliyuncs.com\/debian\/ buster main non-free contrib&quot; &gt; \/etc\/apt\/sources.list) \nRUN (apt-get update) &amp;&amp; (apt-get upgrade -y)\n\n# \u5b89\u88c5\u4f9d\u8d56\u5de5\u5177\uff0cdefault-libmysqlclient-dev \u662f mysqlclient \u7684\u4f9d\u8d56\nRUN (apt-get install -y vim wget httpie netcat-openbsd htop curl gcc make g++ default-libmysqlclient-dev) \n\n# \u5b89\u88c5 node \u73af\u5883\nRUN (apt install -y nodejs npm) &amp;&amp; (npm install -g crypto-js @babel\/core @babel\/cli @babel\/preset-env)<\/code><\/pre>\n<p>\u5f53\u7136\uff0c\u4e0a\u9762\u7684 \u8fd8\u6ca1\u6709\u628a apt \u955c\u50cf\u6e90\u6362\u6210\u5927\u9646\u7684<\/p>\n<p>\u8bf4\u66f4\u52a0\u5b8c\u6574\u7684\u662f\u4e0b\u9762\u8fd9\u6837<\/p>\n<pre><code class=\"Dockerfile\">FROM python:3.11.5-bookworm\n# \u4e3a\u4ec0\u4e48\u8981\u5220\u9664\u8fd9\u4e9b\u4e1c\u897f? \u53c2\u8003\uff1a[\u4e3a\u4ec0\u4e48\u6211\u628a debian12 \u7684 apt \u6e90\u66ff\u6362\u4e3a\u4e0a\u6d77\u4ea4\u5927\u4e4b\u540e\uff0c\u8fd8\u4f1a\u8fde\u63a5 debian \u5b98\u65b9\u6e90\uff1f](https:\/\/segmentfault.com\/q\/1010000044193707)\nRUN rm -rf \/etc\/apt\/sources.list.d\/*\nRUN echo &quot;deb http:\/\/mirror.sjtu.edu.cn\/debian bookworm main non-free contrib&quot; &gt; \/etc\/apt\/sources.list\nRUN (apt-get update) &amp;&amp; (apt-get upgrade -y)\n\n# \u5b89\u88c5\u4f9d\u8d56\u5de5\u5177\uff0cdefault-libmysqlclient-dev \u662f mysqlclient \u7684\u4f9d\u8d56\nRUN (apt-get install -y vim wget httpie netcat-openbsd htop curl gcc make g++ default-libmysqlclient-dev) \n\n# \u5b89\u88c5 node \u73af\u5883\nRUN (apt install -y nodejs npm) &amp;&amp; (npm install -g crypto-js @babel\/core @babel\/cli @babel\/preset-env)<\/code><\/pre>\n<p>\u5c0f\u7ed3\uff1a<\/p>\n<ul>\n<li>\u8981\u7528 debian12\uff0c\u4e5f\u5c31\u662f bookworm\u3002\u4e0d\u5efa\u8bae\u7528 debian10 \u548cdebian11\uff0c\u56e0\u4e3a\u4ed6\u4e24\u81ea\u5e26\u7684\u90fd\u662f nodejs12\uff0c\u592a\u53e4\u8001\u4e86\uff0c\u6beb\u65e0\u610f\u4e49\u3002<\/li>\n<li>\u800c debian12 \u7684 nodejs18 \u8db3\u591f hold \u5927\u591a\u6570\u573a\u666f<\/li>\n<li>\u8bb0\u5f97\u66ff\u6362 apt \u6362\u4e3a\u5927\u9646\u7684\uff0c\u4e0d\u7136\u5728\u5927\u9646\u7684\u4f60\uff0c\u53d7\u4e0d\u4e86<\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000044206429\">https:\/\/segmentfault.com\/a\/1190000044206429<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fc7\u53bb\u4f1a\u4f7f\u7528\u7c7b\u4f3c curl -sL https:\/\/deb.nodesource.com\/setup_16.x  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10008268","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10008268"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008268\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10008268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10008268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10008268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}