{"id":4042,"date":"2025-05-11T15:37:00","date_gmt":"2025-05-11T07:37:00","guid":{"rendered":"https:\/\/www.gaigaiming.com\/?p=4042"},"modified":"2026-05-11T15:41:12","modified_gmt":"2026-05-11T07:41:12","slug":"dockerfile-%e9%85%8d%e7%bd%ae%e5%89%8d%e7%ab%af","status":"publish","type":"post","link":"https:\/\/www.gaigaiming.com\/index.php\/2025\/05\/11\/dockerfile-%e9%85%8d%e7%bd%ae%e5%89%8d%e7%ab%af\/","title":{"rendered":"dockerfile-\u914d\u7f6e\u524d\u7aef"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># \u6784\u5efa\u9636\u6bb5\nFROM node:lts-alpine as build-stage\nWORKDIR \/app\n\n# \u590d\u5236\u4f9d\u8d56\u6e05\u5355\uff0c\u5229\u7528Docker\u7f13\u5b58\nCOPY package.json .\/\nRUN npm install -g pnpm\n\n# \u8df3\u8fc7\u811a\u672c\u6267\u884c\uff0c\u907f\u514d\u7f16\u8bd1\u9519\u8bef\uff08\u524d\u7aef\u9879\u76ee\u5fc5\u5907\uff09\nRUN pnpm install --ignore-scripts\n\n# \u590d\u5236\u9879\u76ee\u6e90\u7801\u5e76\u6784\u5efa\nCOPY . .\nRUN pnpm run build\n\n# \u751f\u4ea7\u9636\u6bb5\uff1a\u4ec5\u4fdd\u7559Nginx + \u6784\u5efa\u4ea7\u7269\nFROM nginx:stable-alpine as production-stage\n\n# \u6e05\u7406\u9ed8\u8ba4\u914d\u7f6e\uff0c\u4f7f\u7528\u81ea\u5b9a\u4e49\u914d\u7f6e\nRUN rm \/etc\/nginx\/conf.d\/default.conf\nCOPY nginx_dev.conf \/etc\/nginx\/conf.d\/nginx.conf\nCOPY mime.types \/etc\/nginx\/mime.types.custom\n\n# \u4ece\u6784\u5efa\u9636\u6bb5\u590d\u5236dist\u6587\u4ef6\nCOPY --from=build-stage \/app\/dist \/usr\/share\/nginx\/html\n\nEXPOSE 80\nCMD &#91;\"nginx\", \"-g\", \"daemon off;\"]<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d\u7684RUN pnpm run build \u5bf9\u5e94\u7684\u662fpackagejson\u4e2d\u7684\u914d\u7f6e<\/p>\n\n\n\n<p>package.json\u6587\u4ef6\u8bbe\u7f6e\uff0c\u5982\u679c\u662f\u751f\u4ea7\u7684\u5c31\u7528 RUN pnpm run test<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"scripts\": {\n    \"build\": \"vue-tsc --noEmit &amp; vite build --mode development\",\n    \"serve\": \"vite\",\n    \"dev\": \"vite\",\n    \"test\": \"vue-tsc --noEmit &amp; vite build --mode production\",\n    \"preview\": \"vite preview\",\n    \"build-only\": \"vite build\",\n    \"type-check\": \"vue-tsc --noEmit\",\n    \"lint:eslint\": \"eslint --cache \\\"src\/**\/*.{vue,ts,js}\\\" --fix\",\n    \"lint:prettier\": \"prettier --write \\\"**\/*.{js,cjs,ts,json,css,scss,vue,html,md}\\\"\",\n    \"lint:stylelint\": \"stylelint --cache \\\"**\/*.{css,scss,vue}\\\" --fix\",\n    \"lint:lint-staged\": \"lint-staged\",\n    \"lint\": \"npm run lint:eslint &amp;&amp; npm run lint:prettier &amp;&amp; npm run lint:stylelint\",\n    \"preinstall\": \"npx only-allow pnpm\",\n    \"prepare\": \"husky\",\n    \"commit\": \"git-cz\"\n  },<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u4e2d\u7684RUN pnpm run build \u5bf9\u5e94\u7684\u662fpackagejson\u4e2d\u7684\u914d\u7f6e package.json\u6587 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-4042","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/4042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/comments?post=4042"}],"version-history":[{"count":1,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/4042\/revisions"}],"predecessor-version":[{"id":4043,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/4042\/revisions\/4043"}],"wp:attachment":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/media?parent=4042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/categories?post=4042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/tags?post=4042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}