From ded9a468c4b1b405133d1cebe0d5c34ab037f4d1 Mon Sep 17 00:00:00 2001 From: hillct Date: Sat, 12 Nov 2016 16:43:47 -0500 Subject: [PATCH 1/3] * Sanitized /examples dependency management * Added Docker deployment support files --- .dockerignore | 4 ++++ Dockerfile | 3 +++ examples/express.js | 6 +++--- examples/hello-world.js | 3 ++- examples/http.js | 2 +- examples/package.json | 17 ----------------- package.json | 1 + 7 files changed, 14 insertions(+), 22 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile delete mode 100644 examples/package.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..0c5d7c58 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.git +.gitignore +*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..09650cd7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM node:6-onbuild +ENV NPM_CONFIG_LOGLEVEL warn +EXPOSE 8080 diff --git a/examples/express.js b/examples/express.js index ac517fb8..59420e51 100644 --- a/examples/express.js +++ b/examples/express.js @@ -1,10 +1,10 @@ console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force -var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 80; +var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080; var express = require('express'); var app = express(); -var Gun = require('gun'); +var Gun = require('../'); var gun = Gun({ file: 'data.json', s3: { @@ -17,4 +17,4 @@ var gun = Gun({ gun.wsp(app); app.use(express.static(__dirname)).listen(port); -console.log('Server started on port ' + port + ' with /gun'); \ No newline at end of file +console.log('Server started on port ' + port + ' with /gun'); diff --git a/examples/hello-world.js b/examples/hello-world.js index 380c8170..23f3f5a7 100644 --- a/examples/hello-world.js +++ b/examples/hello-world.js @@ -1,5 +1,6 @@ -var Gun = require('gun'); +var Gun = require('../'); var gun = Gun({ + file: 'data.json', s3: { key: '', // AWS Access Key secret: '', // AWS Secret Token diff --git a/examples/http.js b/examples/http.js index e3476cf9..06684eba 100644 --- a/examples/http.js +++ b/examples/http.js @@ -1,4 +1,4 @@ -var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 80; +var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080; var Gun = require('../'); var gun = Gun({ diff --git a/examples/package.json b/examples/package.json deleted file mode 100644 index e3eb1358..00000000 --- a/examples/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "examples", - "main": "http.js", - "description": "Example gun apps" -, "version": "0.0.3" -, "engines": { - "node": "~>0.10.x" - } -, "dependencies": { - "express": "~>4.13.4", - "gun": "github:amark/gun#0.5" - } -, "scripts": { - "start": "node http.js", - "test": "mocha" - } -} diff --git a/package.json b/package.json index 9df20e51..18e8b3f1 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ }, "devDependencies": { "mocha": "~>1.9.0", + "express": "~>4.13.4", "panic-server": "~>0.3.0", "selenium-webdriver": "~>2.53.2" } From d47f47baec0aeec8e4967a9f74322e26dbffc7b6 Mon Sep 17 00:00:00 2001 From: hillct Date: Sat, 12 Nov 2016 17:59:15 -0500 Subject: [PATCH 2/3] Add Deployment documentation for Heroku & Docker --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index af561150..fb14d5a6 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,28 @@ Try the [interactive tutorial](http://gun.js.org/think.html) in the browser (**5 If that did not work it is probably because npm installed it to a global directory. To fix that try `mkdir node_modules` in your desired directory and re-run the above commands. You also might have to add `sudo` in front of the commands. +## Quick dev/test Deployments + + - To quickly spin up a Gun test server for your development team, uilize eiher [Heroku](http://heroku.com) or [Docker](http://docker.com) or any variant thereof ([Dokku](http://dokku.viewdocs.io/dokku/), [Flynn.io](http://flynn.io), etc) + +### Docker + ```bash + git clone https://github.com/amark/gun.git + cd gun + docker build -t myrepo/gundb:v1 . + docker run -p 8080:8080 myrepo/gundb:v1 + ``` + Then visit [http://localhost:8080](http://localhost:8080) in your browser. + +### Hiroku + ```bash + git clone https://github.com/amark/gun.git + cd gun + heroku create + git push -f heroku HEAD:master + ``` + Then visit the URL in the output of the 'heroku create' step, in your browser. + ### Videos - [Fault tolerance](https://www.youtube.com/watch?v=-i-11T5ZI9o&feature=youtu.be) (01:01) - [Saving relational or document based data](https://www.youtube.com/watch?v=cOO6wz1rZVY&feature=youtu.be) (06:59) From d1e5f932392ec247d93c6b9d7764e861fe1d2f73 Mon Sep 17 00:00:00 2001 From: hillct Date: Sat, 12 Nov 2016 19:03:16 -0500 Subject: [PATCH 3/3] Added documentation for Now.sh deployment --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb14d5a6..7449fb4d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Try the [interactive tutorial](http://gun.js.org/think.html) in the browser (**5 ## Quick dev/test Deployments - - To quickly spin up a Gun test server for your development team, uilize eiher [Heroku](http://heroku.com) or [Docker](http://docker.com) or any variant thereof ([Dokku](http://dokku.viewdocs.io/dokku/), [Flynn.io](http://flynn.io), etc) + - To quickly spin up a Gun test server for your development team, uilize eiher [Heroku](http://heroku.com) or [Docker](http://docker.com) or any variant thereof ([Dokku](http://dokku.viewdocs.io/dokku/), [Flynn.io](http://flynn.io), [now.sh](https://zeit.co/now), etc) ### Docker ```bash @@ -64,6 +64,15 @@ Try the [interactive tutorial](http://gun.js.org/think.html) in the browser (**5 git push -f heroku HEAD:master ``` Then visit the URL in the output of the 'heroku create' step, in your browser. + +### Now.sh + ```bash + npm install -g now + git clone https://github.com/amark/gun.git + cd gun + now --npm + ``` + Then visit the URL in the output of the 'now --npm' step, in your browser. ### Videos - [Fault tolerance](https://www.youtube.com/watch?v=-i-11T5ZI9o&feature=youtu.be) (01:01)