Skip to content

Commit

Permalink
Rethinkdb (#85)
Browse files Browse the repository at this point in the history
* Fixed EACCES exception thrown when install node packages

* Added compose override file for 2 node example

* Updated .gitignore to only remove root override file

* Added RethinkDB
  • Loading branch information
philtrep authored Jul 10, 2017
1 parent 35b9315 commit 46e8aa5
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jspm_packages

# Project Specific
data
docker-compose.override.yml
./docker-compose.override.yml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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
* [RethinkDB](https://github.com/Osedea/nodock/tree/master/_examples/rethinkdb) - RethinkDB + Node + NGINX
* [2 Node Apps](https://github.com/Osedea/nodock/tree/master/_examples/2-nodes) - Node + Node + NGINX
<a name="Workspace"></a>
Expand Down
17 changes: 17 additions & 0 deletions _examples/2-nodes/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# docker-compose.override.yml

version: '2'

services:
node2: # name of new container
extends: node # extends the settings from the "node" container
build:
context: ./node
args:
- PROJECT_PATH=second-app
entrypoint: run-nodock "node index.js" # the entrypoint for the "node2" container
nginx:
ports:
- "10000:10000" # the port(s) to forward for the "node2" container
links:
- node2 # link "nginx" to "node2"
23 changes: 23 additions & 0 deletions _examples/rethinkdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## RethinkDB Service

### Setup

Copy the index file in this folder to the project root:

```bash
cd <project_folder>/

cp -r nodock/_examples/rethinkdb/* .
```

### Usage

```bash
cd nodock/

docker-compose up -d node rethinkdb nginx
```

By going to `127.0.0.1` in your browser you should be seeing a nice greeting!

You can access the RethinkDB GUI via `127.0.0.1:28080`.
21 changes: 21 additions & 0 deletions _examples/rethinkdb/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var express = require('express');
var app = express();
var r = require('rethinkdb');

app.get('/', function(req, res) {
r.connect({
host: 'rethinkdb',
port: 28015,
authKey: '',
}, function(err) {

if (!err) {
res.send('You are amazing');
} else {
res.send('Could not connect to RethinkDB :(');
}

});
});

app.listen(8000);
15 changes: 15 additions & 0 deletions _examples/rethinkdb/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example-rethinkdb-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",
"rethinkdb": "^2.3.3"
}
}
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ services:
expose:
- "11211"

rethinkdb:
build:
context: ./rethinkdb
volumes:
- ./data/rethinkdb:/data
expose:
- "28015"
- "29015"
ports:
- "28080:8080"

volumes:
image: tianon/true
volumes:
Expand Down
3 changes: 3 additions & 0 deletions node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ ENV NODE_ENV=$NODE_ENV
RUN groupadd -r www-app &&\
useradd -r -g www-app www-app

RUN mkdir -p /home/www-app &&\
chmod 777 /home/www-app -R

# Install the specified NODE_VERSION or grab latest
RUN n "$NODE_VERSION"

Expand Down
2 changes: 1 addition & 1 deletion node/scripts/run-nodock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd $PROJECT_PATH
if [[ $YARN = true ]]; then
su -c "cd $PROJECT_PATH; yarn" -s /bin/bash www-app
else
su -c "cd $PROJECT_PATH; npm i" -s /bin/bash www-app
su -c "cd $PROJECT_PATH; npm i --force" -s /bin/bash www-app
fi

su -c "cd $PROJECT_PATH; $SCRIPT" -s /bin/bash www-app
3 changes: 3 additions & 0 deletions rethinkdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM rethinkdb

CMD ["rethinkdb", "--bind", "all"]

0 comments on commit 46e8aa5

Please sign in to comment.