{"id":4714,"date":"2025-07-25T20:45:11","date_gmt":"2025-07-25T11:45:11","guid":{"rendered":"https:\/\/eternalsphere.net\/echoes\/?p=4714"},"modified":"2025-07-25T20:45:11","modified_gmt":"2025-07-25T11:45:11","slug":"ngjwzqwvoksizct","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2025\/07\/25\/ngjwzqwvoksizct\/","title":{"rendered":"\u4f7f\u7528 Docker \u90e8\u7f72 3D \u592a\u9633\u7cfb\u53ef\u89c6\u5316\u7f51\u7ad9"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Docker \u548c Docker Compose\uff0c\u5feb\u901f\u90e8\u7f72\u4e00\u4e2a\u57fa\u4e8e React Three Fiber \u6784\u5efa\u7684\u4ea4\u4e92\u5f0f 3D \u592a\u9633\u7cfb\u6a21\u62df\u5668\u3002\u8be5\u9879\u76ee\u9002\u7528\u4e8e\u5c55\u793a\u3001\u6559\u5b66\u6216\u4e2a\u4eba\u7f51\u7ad9\u5d4c\u5165\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\uddf1 \u9879\u76ee\u7b80\u4ecb<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u53ef\u89c6\u5316\u9879\u76ee\u91c7\u7528\u4ee5\u4e0b\u6280\u672f\u6808\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>React + Three.js + React Three Fiber<\/strong>\uff1a\u6e32\u67d3 3D \u573a\u666f\u4e0e\u661f\u4f53<\/li>\n\n\n\n<li><strong>Vite<\/strong>\uff1a\u6784\u5efa\u524d\u7aef\u5e94\u7528<\/li>\n\n\n\n<li><strong>Nginx<\/strong>\uff1a\u4f5c\u4e3a\u9759\u6001\u8d44\u6e90\u670d\u52a1\u5668<\/li>\n\n\n\n<li><strong>Docker<\/strong>\uff1a\u9694\u79bb\u90e8\u7f72\u73af\u5883\uff0c\u5feb\u901f\u4e0a\u7ebf\u4e0e\u56de\u6eda<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udc33 \u90e8\u7f72\u6b65\u9aa4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u514b\u9686\u9879\u76ee\u4ee3\u7801<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>git clone https:\/\/github.com\/&lt;\u7528\u6237\u540d&gt;\/solar_system.git<br>cd solar_system<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u521b\u5efa <code>Dockerfile<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># \u6784\u5efa\u9636\u6bb5<br>FROM node:18-alpine AS builder<br>WORKDIR \/app<br>COPY . .<br>RUN npm install<br>RUN npm run build<br><br># \u751f\u4ea7\u90e8\u7f72\u9636\u6bb5<br>FROM nginx:alpine<br>COPY --from=builder \/app\/dist \/usr\/share\/nginx\/html<br>COPY nginx.conf \/etc\/nginx\/conf.d\/default.conf<br>EXPOSE 80<br>CMD [\"nginx\", \"-g\", \"daemon off;\"]<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u53ef\u9009\uff1a<code>nginx.conf<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>server {<br>  listen 80;<br>  server_name localhost;<br><br>  root \/usr\/share\/nginx\/html;<br>  index index.html;<br><br>  location \/ {<br>    try_files $uri $uri\/ \/index.html;<br>  }<br>}<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u7f16\u5199 <code>docker-compose.yml<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>version: '3.8'<br><br>services:<br>  solar-system:<br>    build: .<br>    ports:<br>      - \"&lt;\u81ea\u5b9a\u4e49\u4e3b\u673a\u7aef\u53e3&gt;:80\"<br>    container_name: solar-system-viewer<br>    restart: unless-stopped<br><\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f \u8bf7\u5c06 <code>&lt;\u81ea\u5b9a\u4e49\u4e3b\u673a\u7aef\u53e3&gt;<\/code> \u66ff\u6362\u4e3a\u672a\u88ab\u5360\u7528\u7684\u7aef\u53e3\uff08\u5982 3000\u30018888 \u7b49\uff09<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u6784\u5efa\u5e76\u542f\u52a8\u5bb9\u5668<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>docker-compose build<br>docker-compose up -d<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u6d4f\u89c8\u5668\u8bbf\u95ee<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>http:\/\/localhost:&lt;\u81ea\u5b9a\u4e49\u4e3b\u673a\u7aef\u53e3&gt;<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>http:\/\/&lt;\u670d\u52a1\u5668IP&gt;:&lt;\u81ea\u5b9a\u4e49\u4e3b\u673a\u7aef\u53e3&gt;<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccb \u5e38\u7528\u547d\u4ee4<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u64cd\u4f5c<\/th><th>\u547d\u4ee4<\/th><\/tr><\/thead><tbody><tr><td>\u6784\u5efa\u955c\u50cf<\/td><td><code>docker-compose build<\/code><\/td><\/tr><tr><td>\u542f\u52a8\u5bb9\u5668<\/td><td><code>docker-compose up -d<\/code><\/td><\/tr><tr><td>\u505c\u6b62\u5e76\u6e05\u7406\u5bb9\u5668<\/td><td><code>docker-compose down<\/code><\/td><\/tr><tr><td>\u67e5\u770b\u65e5\u5fd7<\/td><td><code>docker-compose logs -f<\/code><\/td><\/tr><tr><td>\u53d8\u66f4\u540e\u91cd\u5efa\u5e76\u91cd\u542f<\/td><td><code>docker-compose up --build -d<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u90e8\u7f72\u4f18\u52bf<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b8c\u6574\u5c01\u88c5\uff0c\u65e0\u9700\u5b89\u88c5 Node\/npm \u73af\u5883<\/li>\n\n\n\n<li>\u4e00\u952e\u542f\u52a8\uff0c\u9002\u5408\u672c\u5730\u6d4b\u8bd5\u4e0e\u8fdc\u7a0b\u90e8\u7f72<\/li>\n\n\n\n<li>\u81ea\u5e26\u524d\u7aef\u8def\u7531\u517c\u5bb9\uff08\u907f\u514d\u5237\u65b0 404\uff09<\/li>\n\n\n\n<li>\u652f\u6301\u955c\u50cf\u8fc1\u79fb\u3001\u5feb\u901f\u5907\u4efd\u4e0e\u6062\u590d<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udce6 \u4f7f\u7528\u573a\u666f<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u79d1\u666e\u6f14\u793a\u6216\u6559\u5b66\u7f51\u7ad9\u5d4c\u5165<\/li>\n\n\n\n<li>\u4ea4\u4e92\u5f0f\u4f5c\u54c1\u96c6\u6216\u5c55\u793a\u9875\u9762<\/li>\n\n\n\n<li>\u4e2a\u4eba\u9879\u76ee\u90e8\u7f72\u7684\u7ec3\u624b\u6848\u4f8b<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Docker \u548c Docker Compose\uff0c\u5feb\u901f\u90e8\u7f72\u4e00\u4e2a\u57fa\u4e8e React Three Fiber \u6784\u5efa\u7684\u4ea4\u4e92\u5f0f 3D \u592a\u9633\u7cfb\u6a21\u62df\u5668\u3002\u8be5\u9879\u76ee\u9002\u7528\u4e8e\u5c55\u793a\u3001\u6559\u5b66\u6216\u4e2a\u4eba\u7f51\u7ad9\u5d4c\u5165\u3002 \ud83e\uddf1 \u9879\u76ee\u7b80\u4ecb \u8be5\u53ef\u89c6\u5316\u9879\u76ee\u91c7\u7528\u4ee5\u4e0b\u6280\u672f\u6808\uff1a \ud83d\udc33 \u90e8\u7f72\u6b65\u9aa4 1. \u514b\u9686\u9879\u76ee\u4ee3\u7801 git clone https:\/\/github.com\/&lt;\u7528\u6237\u540d&gt;\/solar_system.gitcd solar_system 2. \u521b\u5efa Dockerfile # \u6784\u5efa\u9636\u6bb5FROM node:18-alpine AS builderWORKDIR \/appCOPY . .RUN npm installRUN npm run build# \u751f\u4ea7\u90e8\u7f72\u9636\u6bb5FROM nginx:alpineCOPY &#8211;from=builder \/app\/dist \/usr\/share\/nginx\/htmlCOPY nginx.conf \/etc\/nginx\/conf.d\/default.confEXPOSE 80CMD [&#8220;nginx&#8221;, &#8220;-g&#8221;, &#8220;daemon off;&#8221;] &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-4714","post","type-post","status-publish","format-standard","hentry","category-ayo0bcjn5seq2"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/comments?post=4714"}],"version-history":[{"count":1,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4714\/revisions"}],"predecessor-version":[{"id":4715,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4714\/revisions\/4715"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=4714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=4714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=4714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}