commit 074954e90af689edc3060cdc1329552abfd719c0
parent b8db8e1b45b35878864c8fc882296991ffd3ee2c
Author: Konstantin Tarkus <koistya@gmail.com>
Date: Tue, 20 Dec 2016 11:34:30 +0300
Add Dockerfile (#1038)
Update package.json/name, then: npm run build -- --release --docker
Diffstat:
4 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/Dockerfile b/Dockerfile
@@ -0,0 +1,8 @@
+FROM node:7.2.1-alpine
+
+COPY ./build /srv/www
+WORKDIR /srv/www
+
+RUN npm install --production --silent
+
+CMD [ "node", "server.js" ]
diff --git a/docs/getting-started.md b/docs/getting-started.md
@@ -112,6 +112,13 @@ or, for a production build:
```shell
$ npm run build -- --release
```
+
+or, for a production docker build:
+
+```shell
+$ npm run build -- --release --docker
+```
+
*NOTE: double dashes are required*
After running this command, the `/build` folder will contain the compiled
diff --git a/package.json b/package.json
@@ -1,4 +1,6 @@
{
+ "name": "web",
+ "version": "0.0.0",
"private": true,
"engines": {
"node": ">=6.5",
diff --git a/tools/build.js b/tools/build.js
@@ -7,11 +7,13 @@
* LICENSE.txt file in the root directory of this source tree.
*/
+import cp from 'child_process';
import run from './run';
import clean from './clean';
import copy from './copy';
import bundle from './bundle';
import render from './render';
+import pkg from '../package.json';
/**
* Compiles the project from source files into a distributable
@@ -25,6 +27,10 @@ async function build() {
if (process.argv.includes('--static')) {
await run(render);
}
+
+ if (process.argv.includes('--docker')) {
+ cp.spawnSync('docker', ['build', '-t', pkg.name, '.'], { stdio: 'inherit' });
+ }
}
export default build;