diff --git a/README.md b/README.md index 55c9160..72a0664 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ We provide examples of configurations you might use for a specific stack. Each e * [Mongo](https://github.com/Osedea/nodock/tree/master/_examples/mongo) - MongoDB + Node + NGINX * [RabbitMQ](https://github.com/Osedea/nodock/tree/master/_examples/rabbitmq) - RabbitMQ + Node + NGINX * [Memcached](https://github.com/Osedea/nodock/tree/master/_examples/memcached) - Memcached + Node + NGINX +* [2 Node Apps](https://github.com/Osedea/nodock/tree/master/_examples/2-nodes) - Node + Node + NGINX ## Workspace diff --git a/_examples/2-nodes/README.md b/_examples/2-nodes/README.md new file mode 100644 index 0000000..3a0a25e --- /dev/null +++ b/_examples/2-nodes/README.md @@ -0,0 +1,23 @@ +## 2 Nodes + +### Setup + +Copy all the files in this folder to the project root: + +```bash +cd / + +cp -r nodock/_examples/multiple-node/* . +mv docker-compose.override.yml nodock/ +mv node2.conf nodock/nginx/sites/ +``` + +### Usage + +```bash +cd nodock/ + +docker-compose up -d node node2 nginx +``` + +By going to `127.0.0.1` in your browser you should be seeing a nice greeting! By going to `127.0.0.1:10000` in your browser you should be seeing _another_ nice greeting! \ No newline at end of file diff --git a/_examples/2-nodes/index.js b/_examples/2-nodes/index.js new file mode 100644 index 0000000..05b3fdd --- /dev/null +++ b/_examples/2-nodes/index.js @@ -0,0 +1,8 @@ +var express = require('express'); +var app = express(); + +app.get('/', function(req, res) { + res.send('You are amazing'); +}); + +app.listen(8000); diff --git a/_examples/2-nodes/node2.conf b/_examples/2-nodes/node2.conf new file mode 100644 index 0000000..e3f2b59 --- /dev/null +++ b/_examples/2-nodes/node2.conf @@ -0,0 +1,7 @@ +server { + listen 10000 default_server; + + location / { + proxy_pass http://node2:10000; # Note that `node2` is the name of the service + } +} diff --git a/_examples/2-nodes/package.json b/_examples/2-nodes/package.json new file mode 100644 index 0000000..981857c --- /dev/null +++ b/_examples/2-nodes/package.json @@ -0,0 +1,14 @@ +{ + "name": "example-2-node-docker", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT", + "dependencies": { + "express": "^4.14.0" + } +} diff --git a/_examples/2-nodes/second-app/index.js b/_examples/2-nodes/second-app/index.js new file mode 100644 index 0000000..6acb42a --- /dev/null +++ b/_examples/2-nodes/second-app/index.js @@ -0,0 +1,8 @@ +var express = require('express'); +var app = express(); + +app.get('/', function(req, res) { + res.send('You are pretty cool'); +}); + +app.listen(10000); diff --git a/_examples/2-nodes/second-app/package.json b/_examples/2-nodes/second-app/package.json new file mode 100644 index 0000000..5277d45 --- /dev/null +++ b/_examples/2-nodes/second-app/package.json @@ -0,0 +1,14 @@ +{ + "name": "example-multiple-node-docker", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT", + "dependencies": { + "express": "^4.14.0" + } +} diff --git a/nginx/sites/node2.conf b/nginx/sites/node2.conf new file mode 100644 index 0000000..e3f2b59 --- /dev/null +++ b/nginx/sites/node2.conf @@ -0,0 +1,7 @@ +server { + listen 10000 default_server; + + location / { + proxy_pass http://node2:10000; # Note that `node2` is the name of the service + } +}