From da33f0a5e348ef9d111446898dc4433055b7806f Mon Sep 17 00:00:00 2001 From: jasonwalsh Date: Tue, 24 Apr 2018 20:06:52 -0400 Subject: [PATCH 1/2] Add Docker components Signed-off-by: jasonwalsh --- .dockerignore | 138 +++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 7 +++ README.md | 9 +++ docker-compose.yml | 13 +++++ 4 files changed, 167 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..899692d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,138 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# .tfvars files +*.tfvars +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + +.git/ +.gitignore +.travis.yml +LICENSE +Procfile +docker-compose.yml +terraform/ +yarn.lock diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dfba830 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:alpine +WORKDIR /srv +COPY package.json . +RUN yarn install --frozen-lockfile --no-bin-links --silent +COPY . . +EXPOSE 3000 +CMD [ "npm", "start" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..81c6957 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +[![Build Status](https://travis-ci.com/jasonwalsh/prototype.svg?token=kDZcsygosGgqF2WJJ1jZ&branch=master)](https://travis-ci.com/jasonwalsh/prototype) + +## Docker + +This repository uses Docker [Community Edition](https://www.docker.com/community-edition) (CE) version `18.03.0-ce`. + + $ docker-compose up -d + +The `-d` flag instructs Docker to run the containers in 'detached' mode. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a1e3559 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + bot: + build: . + environment: + ACCESS_TOKEN: '${ACCESS_TOKEN:?err}' + PORT: '${PORT:-3000}' + VERIFY_TOKEN: '${VERIFY_TOKEN:?err}' + ports: + - 3000:3000 + volumes: + - .:/srv + - /srv/node_modules +version: '3.6' From 5e6bb2843e726e130ddaf93c8f583c772a689cb9 Mon Sep 17 00:00:00 2001 From: jasonwalsh Date: Wed, 25 Apr 2018 17:50:55 -0400 Subject: [PATCH 2/2] Add Docker test components Signed-off-by: jasonwalsh --- Dockerfile | 5 +++-- README.md | 4 ++++ docker-compose.test.yml | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 docker-compose.test.yml diff --git a/Dockerfile b/Dockerfile index dfba830..204d3c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM node:alpine +ARG NODE_ENV=production WORKDIR /srv COPY package.json . -RUN yarn install --frozen-lockfile --no-bin-links --silent +RUN NODE_ENV=$NODE_ENV yarn install --frozen-lockfile --silent COPY . . EXPOSE 3000 -CMD [ "npm", "start" ] +CMD [ "yarn", "run", "start" ] diff --git a/README.md b/README.md index 81c6957..90ddf58 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,7 @@ This repository uses Docker [Community Edition](https://www.docker.com/community $ docker-compose up -d The `-d` flag instructs Docker to run the containers in 'detached' mode. + +## Testing + + $ docker-compose -f docker-compose.test.yml up diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..9164d11 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,8 @@ +services: + sut: + build: + args: + NODE_ENV: development + context: . + command: yarn run test +version: '3.6'