瀏覽代碼

Utillize build cache for Node.js web app example

Signed-off-by: Hans Kristian Flaatten <hans@starefossen.com>
Hans Kristian Flaatten 9 年之前
父節點
當前提交
641c739fc1
共有 1 個文件被更改,包括 10 次插入7 次删除
  1. 10 7
      docs/examples/nodejs_web_app.md

+ 10 - 7
docs/examples/nodejs_web_app.md

@@ -85,17 +85,18 @@ via-package-manager#rhelcentosscientific-linux-6):
     # Install Node.js and npm
     # Install Node.js and npm
     RUN     yum install -y nodejs npm
     RUN     yum install -y nodejs npm
 
 
+Install your app dependencies using the `npm` binary:
+
+    # Install app dependencies
+    COPY package.json /src/package.json
+    RUN cd /src; npm install
+
 To bundle your app's source code inside the Docker image, use the `COPY`
 To bundle your app's source code inside the Docker image, use the `COPY`
 instruction:
 instruction:
 
 
     # Bundle app source
     # Bundle app source
     COPY . /src
     COPY . /src
 
 
-Install your app dependencies using the `npm` binary:
-
-    # Install app dependencies
-    RUN cd /src; npm install
-
 Your app binds to port `8080` so you'll use the `EXPOSE` instruction to have
 Your app binds to port `8080` so you'll use the `EXPOSE` instruction to have
 it mapped by the `docker` daemon:
 it mapped by the `docker` daemon:
 
 
@@ -116,11 +117,13 @@ Your `Dockerfile` should now look like this:
     # Install Node.js and npm
     # Install Node.js and npm
     RUN     yum install -y nodejs npm
     RUN     yum install -y nodejs npm
 
 
-    # Bundle app source
-    COPY . /src
     # Install app dependencies
     # Install app dependencies
+    COPY package.json /src/package.json
     RUN cd /src; npm install
     RUN cd /src; npm install
 
 
+    # Bundle app source
+    COPY . /src
+
     EXPOSE  8080
     EXPOSE  8080
     CMD ["node", "/src/index.js"]
     CMD ["node", "/src/index.js"]