From c5d49ff176620bce35e114747c4512ae1ac13adf Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 11:20:51 +0100 Subject: [PATCH 01/14] Add CircleCI config --- .circleci/config.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..06cb6bf --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,32 @@ +# Javascript Node CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/node:8.1.4 + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: yarn install + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + # run tests! + - run: yarn test From cd6dfc2cfab8f6a206a778816a1b6f5cdac36235 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:14:31 +0100 Subject: [PATCH 02/14] Docker config --- Dockerfile | 8 ++++++++ bin/hubot | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d522f1e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM node:8.1.4 + +WORKDIR /berend + +# Copy the current directory contents into the container at /app +ADD . /berend + +RUN yarn install diff --git a/bin/hubot b/bin/hubot index 1738780..1cc2a08 100755 --- a/bin/hubot +++ b/bin/hubot @@ -2,7 +2,7 @@ set -e -npm install +#npm install export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" exec node_modules/.bin/hubot --name "Berend" "$@" From b75423f9c0bca4781170680d153f3695a30528fd Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:14:38 +0100 Subject: [PATCH 03/14] Docker compose config --- docker-compose.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b8236ac --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '2' +services: + web: + build: . + command: "/berend/bin/hubot --adapter slack" + ports: + - "8080:8080" From e34a66c81ec2f19db6a772ee94eed0371e2a72c7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:14:45 +0100 Subject: [PATCH 04/14] Vagrant config --- Vagrantfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Vagrantfile diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..ac2f2bc --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,47 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/trusty64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + vb.name = "Berend" + vb.memory = "2048" + end + + config.vm.provision :docker + config.vm.provision :docker_compose, + compose_version: '1.17.1', + yml: '/vagrant/docker-compose.yml', + project_name: 'berend', + run: 'always' +end From 98e599e5dba4aeb9ab03e41d929c7ee38c126f2b Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:15:02 +0100 Subject: [PATCH 05/14] Update gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e9049bb..577dc0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ node_modules .DS_Store* .hubot_history +.idea +.vagrant + From 044473cbb274157cbefd185a0fd6a329352d5031 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 31 Aug 2017 15:39:41 +0200 Subject: [PATCH 06/14] Update .env.example with example values --- .env.example | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 1d46637..d4a39bf 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,9 @@ -HEROKU_URL=https://berend-botje.herokuapp.com -HUBOT_GITHUB_EVENT_NOTIFIER_ROOM=zuidlaren +HEROKU_URL=https://my-app.herokuapp.com +HUBOT_GITHUB_EVENT_NOTIFIER_ROOM=my-event-room HUBOT_GITHUB_EVENT_NOTIFIER_TYPES=pull_request:opened,pull_request:assigned,pull_request:review_requested,issues:opened,issues:assigned,issue_comment,pull_request_review:submitted,status -HUBOT_GITHUB_USERS=wesleydebruijn:wesley,delneet:danieldelnaaij,DeRidder:peter,Jumba:cwongloising -HUBOT_HEROKU_KEEPALIVE_URL=https://berend-botje.herokuapp.com/ -HUBOT_SLACK_BOTNAME=Berend -HUBOT_SLACK_TEAM=Websend +HUBOT_GITHUB_USERS=github_username:slack_username,other_github_username:other_slack_username +HUBOT_HEROKU_KEEPALIVE_URL=https://my-app.herokuapp.com/ +HUBOT_SLACK_BOTNAME=Hubot +HUBOT_SLACK_TEAM=MySlackTeam HUBOT_SLACK_TOKEN=xoxb-secret TZ=Europe/Amsterdam From 9242bafe5658cf594303d78c48a73734fe584d13 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:57:47 +0100 Subject: [PATCH 07/14] Ignore dotenv file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 577dc0d..1e837c8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules .idea .vagrant +.env From 5fa7bb4dddda232e4219c90b058a8ba5fd4a8461 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:58:27 +0100 Subject: [PATCH 08/14] Use node 8.8 image --- .circleci/config.yml | 2 +- Dockerfile | 3 +-- package.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 06cb6bf..6dcd627 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: build: docker: # specify the version you desire here - - image: circleci/node:8.1.4 + - image: circleci/node:8.8 working_directory: ~/repo diff --git a/Dockerfile b/Dockerfile index d522f1e..77b9d73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ -FROM node:8.1.4 +FROM node:8.8 WORKDIR /berend -# Copy the current directory contents into the container at /app ADD . /berend RUN yarn install diff --git a/package.json b/package.json index bd81deb..6232f9c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "scraper": "0.0.9" }, "engines": { - "node": "8.1.4", "npm": "*" + "node": "8.8", } } From 3a0c39dccbb66d9874d4c4628aca0c1bc4beea5b Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 12:59:27 +0100 Subject: [PATCH 09/14] Use Yarn instead of Npm And install node packages on image build, not on container init. --- bin/hubot | 1 - bin/hubot.cmd | 2 +- package.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/hubot b/bin/hubot index 1cc2a08..8f16e7d 100755 --- a/bin/hubot +++ b/bin/hubot @@ -2,7 +2,6 @@ set -e -#npm install export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" exec node_modules/.bin/hubot --name "Berend" "$@" diff --git a/bin/hubot.cmd b/bin/hubot.cmd index 35c9c6f..d8ee198 100644 --- a/bin/hubot.cmd +++ b/bin/hubot.cmd @@ -1,3 +1,3 @@ @echo off -npm install && node_modules\.bin\hubot.cmd --name "Berend" %* \ No newline at end of file +node_modules\.bin\hubot.cmd --name "Berend" %* diff --git a/package.json b/package.json index 6232f9c..e089fa9 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "scraper": "0.0.9" }, "engines": { - "npm": "*" "node": "8.8", + "yarn": "*" } } From 2ea29ea4974d7207aa9331e1178e81aa38193450 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 13:12:49 +0100 Subject: [PATCH 10/14] Use local .env file for secrets This requires your environment to have a `.env` file. See README.md for details --- .env.example | 4 +--- README.md | 8 ++++---- docker-compose.yml | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index d4a39bf..7159502 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,7 @@ -HEROKU_URL=https://my-app.herokuapp.com +# Example HUBOT_GITHUB_EVENT_NOTIFIER_ROOM=my-event-room HUBOT_GITHUB_EVENT_NOTIFIER_TYPES=pull_request:opened,pull_request:assigned,pull_request:review_requested,issues:opened,issues:assigned,issue_comment,pull_request_review:submitted,status HUBOT_GITHUB_USERS=github_username:slack_username,other_github_username:other_slack_username -HUBOT_HEROKU_KEEPALIVE_URL=https://my-app.herokuapp.com/ HUBOT_SLACK_BOTNAME=Hubot HUBOT_SLACK_TEAM=MySlackTeam HUBOT_SLACK_TOKEN=xoxb-secret -TZ=Europe/Amsterdam diff --git a/README.md b/README.md index d422134..f5efc27 100644 --- a/README.md +++ b/README.md @@ -20,21 +20,21 @@ Berend will notify a developer directly when: * a build has finished in Jenkins of his/her commit in a branch ## Configuration -Berend can easily be deployed on a free Heroku instance. Only the GitHub repository needs to be connected in Heroku and you're good to go. +Berend runs inside Docker on a node 8.8 image. +Yarn packages are installed when building the image. +See the Dockerfile and docker-compose.yml for more details. + ### Environment variables The following environment variables are required to run Berend. See .env.example for an example. ``` -HEROKU_URL HUBOT_GITHUB_EVENT_NOTIFIER_ROOM // Name of global chatroom in Slack HUBOT_GITHUB_EVENT_NOTIFIER_TYPES // Accepted GitHub events HUBOT_GITHUB_USERS // Mapping of GitHub/Slack users (wesleydebruijn:wesley) -HUBOT_HEROKU_KEEPALIVE_URL // Heroku URL HUBOT_SLACK_BOTNAME // Slack name HUBOT_SLACK_TEAM // Slack team name HUBOT_SLACK_TOKEN // Token to get access to Slack -TZ // Timezone ``` diff --git a/docker-compose.yml b/docker-compose.yml index b8236ac..cbb467f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,3 +5,5 @@ services: command: "/berend/bin/hubot --adapter slack" ports: - "8080:8080" + env_file: + - .env From 4611393ec412eae47e5eb0a06ad0b5a1b7e20281 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 13:14:33 +0100 Subject: [PATCH 11/14] Rebuild image when vagrant upping --- Vagrantfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index ac2f2bc..e506182 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -43,5 +43,6 @@ Vagrant.configure("2") do |config| compose_version: '1.17.1', yml: '/vagrant/docker-compose.yml', project_name: 'berend', - run: 'always' + run: 'always', + rebuild: true end From a784b78bbf7b9e1611b8009232307989decaaaac Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 13:14:56 +0100 Subject: [PATCH 12/14] Remove unused packages --- external-scripts.json | 4 +--- package.json | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/external-scripts.json b/external-scripts.json index 6871c24..8633276 100644 --- a/external-scripts.json +++ b/external-scripts.json @@ -1,7 +1,5 @@ [ "hubot-diagnostics", "hubot-help", - "hubot-heroku-keepalive", - "hubot-redis-brain", - "hubot-rules" + "hubot-redis-brain" ] diff --git a/package.json b/package.json index e089fa9..aebfddf 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,7 @@ "hubot": "^2.16.0", "hubot-diagnostics": "0.0.1", "hubot-help": "^0.1.2", - "hubot-heroku-keepalive": "^1.0.0", "hubot-redis-brain": "0.0.3", - "hubot-rules": "^0.1.1", "hubot-scripts": "*", "hubot-slack": "^3.4.1", "lodash": "^2.4.1", From bb58acb8999587e610e8cdce52b8f7d1bc5e2082 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 13:18:01 +0100 Subject: [PATCH 13/14] Rename web service to bot --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index cbb467f..223ac6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ version: '2' services: - web: + bot: build: . command: "/berend/bin/hubot --adapter slack" ports: From bb9bd87b136198b702329f5feb7c90d0e91e692c Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Nov 2017 13:18:33 +0100 Subject: [PATCH 14/14] Bump node project version to 0.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aebfddf..d969581 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Berend", - "version": "0.1.0", + "version": "0.2.0", "private": true, "author": "Daniel ", "description": "Berend Botje",