diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f43f53c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git/ +node_modules/ +dist/ +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c912881 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:8.5.0 +WORKDIR /app +COPY . /app + +RUN yarn global add pm2 +RUN yarn install && yarn run build + +HEALTHCHECK --interval=20s --timeout=3s --retries=3 \ + CMD curl -f http://localhost:8080 || exit 1 + +EXPOSE 8080 +CMD ["pm2-docker", "process.yml", "--web", "--json"] diff --git a/docs/Build-Process.md b/docs/Build-Process.md index f901e6d..540744b 100644 --- a/docs/Build-Process.md +++ b/docs/Build-Process.md @@ -6,6 +6,11 @@ There are two build process, one for the client and one for the server. You can start the build process with `npm/yarn run build`. You can also run only the client or the server build process with `yarn run build:client`, `yarn run build:server`. +## Building with Docker + +You can run this projct as a docker image with a pm2 load balancer inside. First run `docker build -t projectname ` and then `docker run -p 8080:8080 projectname:latest`. + + ## Build Variables Specify the `BUILD_LANGUAGE` environment variable (two letter language code defined in `config.js`) to build the project for a different language, by default `BUILD_LANGUAGE` is `en`. diff --git a/process.yml b/process.yml new file mode 100644 index 0000000..715b752 --- /dev/null +++ b/process.yml @@ -0,0 +1,5 @@ +apps: + - script : 'server.js' + name : 'vue-webpack-ssr-fully-featured' + exec_mode: 'cluster' + instances: 4 \ No newline at end of file