From cd7dc9125fff1af5c023d19ac13d368a8fd4c6e5 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Sat, 28 Dec 2019 11:37:51 +0000 Subject: Add docker/travis support --- .travis.yml | 9 +++++++++ Dockerfile | 7 +++++++ config/database-docker.js | 3 +++ docker-compose.yml | 10 ++++++++++ 4 files changed, 29 insertions(+) create mode 100644 .travis.yml create mode 100644 Dockerfile create mode 100644 config/database-docker.js create mode 100644 docker-compose.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6feafff --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: minimal + +services: + - docker + +script: + - docker-compose up --build + - curl -v http://localhost:3000/ + - curl -v http://localhost:3000/new/event/public \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..65b1725 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:13-alpine +WORKDIR /app +ADD package.json package-lock.json /app/ +RUN npm install +COPY . /app/ +RUN cp config/api-example.js config/api.js && cp config/database-docker.js config/database.js +CMD npm start diff --git a/config/database-docker.js b/config/database-docker.js new file mode 100644 index 0000000..78a29a8 --- /dev/null +++ b/config/database-docker.js @@ -0,0 +1,3 @@ +module.exports = { + 'url' : 'mongodb://mongo:27017/gathio' // For local MongoDB connection +}; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d16e279 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' +services: + gathio: + build: . + links: + - mongo + ports: + - 3000:3000 + mongo: + image: mongo:latest \ No newline at end of file -- cgit v1.2.3 From b81fc16224a400cefe789fcbfb0443e25d74b8b9 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Sat, 28 Dec 2019 11:42:03 +0000 Subject: Run docker compose in background --- .gitignore | 1 + .travis.yml | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a31f385..1dc3629 100755 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ config/api.js config/database.js public/events/* !public/events/.gitkeep +wait-for-it.sh # Logs logs diff --git a/.travis.yml b/.travis.yml index 6feafff..4bdce21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,13 @@ -language: minimal +language: shell +os: linux services: - docker script: - - docker-compose up --build + - docker-compose up --build & + - curl https://raw.githubusercontent.com/vishnubob/wait-for-it/9995b721327eac7a88f0dce314ea074d5169634f/wait-for-it.sh -o wait-for-it.sh + - chmod +x wait-for-it.sh + - ./wait-for-it-sh localhost:3000 --timeout=0 - curl -v http://localhost:3000/ - curl -v http://localhost:3000/new/event/public \ No newline at end of file -- cgit v1.2.3 From a3bbcfe3ebd61694304ef5c085a65dadbfa8e206 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Sat, 28 Dec 2019 12:07:26 +0000 Subject: Make sure travis dies if a step fails --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bdce21..064325f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ services: - docker script: - - docker-compose up --build & - - curl https://raw.githubusercontent.com/vishnubob/wait-for-it/9995b721327eac7a88f0dce314ea074d5169634f/wait-for-it.sh -o wait-for-it.sh - - chmod +x wait-for-it.sh - - ./wait-for-it-sh localhost:3000 --timeout=0 - - curl -v http://localhost:3000/ - - curl -v http://localhost:3000/new/event/public \ No newline at end of file + - docker-compose up --build& || travis_terminate 1 + - curl https://raw.githubusercontent.com/vishnubob/wait-for-it/9995b721327eac7a88f0dce314ea074d5169634f/wait-for-it.sh -o wait-for-it.sh || travis_terminate 1 + - chmod +x wait-for-it.sh || travis_terminate 1 + - ./wait-for-it-sh localhost:3000 --timeout=0 || travis_terminate 1 + - curl -v http://localhost:3000/ || travis_terminate 1 + - curl -v http://localhost:3000/new/event/public || travis_terminate 1 \ No newline at end of file -- cgit v1.2.3 From ffb5de97b95be9781a3fb4b70d778993b8c8c1e0 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Sat, 28 Dec 2019 23:10:51 +0000 Subject: Redo Travis testing in a script --- .travis.yml | 7 +------ test.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100755 test.sh diff --git a/.travis.yml b/.travis.yml index 064325f..cdf8b48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,4 @@ services: - docker script: - - docker-compose up --build& || travis_terminate 1 - - curl https://raw.githubusercontent.com/vishnubob/wait-for-it/9995b721327eac7a88f0dce314ea074d5169634f/wait-for-it.sh -o wait-for-it.sh || travis_terminate 1 - - chmod +x wait-for-it.sh || travis_terminate 1 - - ./wait-for-it-sh localhost:3000 --timeout=0 || travis_terminate 1 - - curl -v http://localhost:3000/ || travis_terminate 1 - - curl -v http://localhost:3000/new/event/public || travis_terminate 1 \ No newline at end of file + - ./test.sh \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..6626437 --- /dev/null +++ b/test.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -eux -o pipefail + +cleanup() { + docker-compose kill +} +trap cleanup 0 + +docker-compose up --build & + +while [[ "$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/)" -ne "200" ]]; do sleep 5; done +curl -v http://localhost:3000/new/event/public + +cleanup \ No newline at end of file -- cgit v1.2.3 From 4c72d7706b1294e96cbac1e80dcff7f11be74406 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Sat, 28 Dec 2019 23:11:04 +0000 Subject: Fix comment in Dockerised config --- config/database-docker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database-docker.js b/config/database-docker.js index 78a29a8..7847097 100644 --- a/config/database-docker.js +++ b/config/database-docker.js @@ -1,3 +1,3 @@ module.exports = { - 'url' : 'mongodb://mongo:27017/gathio' // For local MongoDB connection + 'url' : 'mongodb://mongo:27017/gathio' // For dockerised MongoDB connection }; -- cgit v1.2.3 From 9ee5d0f4fb7237797b1f6920f1ecfd5bea659977 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Sat, 28 Dec 2019 23:13:42 +0000 Subject: Don't need wait-for-it anymore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1dc3629..a31f385 100755 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ config/api.js config/database.js public/events/* !public/events/.gitkeep -wait-for-it.sh # Logs logs -- cgit v1.2.3 From ae5e25d7d8a1edac542adf5e5510105aca76c0d9 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Tue, 7 Jan 2020 09:33:35 +0000 Subject: Add Travis badge to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d40c0f0..cfa53d3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # gathio +[![Build Status](https://travis-ci.com/palfrey/gathio.svg?branch=master)](https://travis-ci.com/palfrey/gathio) Self-destructing, shareable, no-registration event pages. -- cgit v1.2.3 From 452c9f42f3769035cdb73e143283eff814de544d Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Tue, 7 Jan 2020 09:43:45 +0000 Subject: Add new config/domain.js setup --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 65b1725..a436239 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,5 +3,5 @@ WORKDIR /app ADD package.json package-lock.json /app/ RUN npm install COPY . /app/ -RUN cp config/api-example.js config/api.js && cp config/database-docker.js config/database.js +RUN cp config/api-example.js config/api.js && cp config/domain-example.js config/domain.js && cp config/database-docker.js config/database.js CMD npm start -- cgit v1.2.3