Skip to content

Commit 46e8aa5

Browse files
authored
Rethinkdb (#85)
* 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
1 parent 35b9315 commit 46e8aa5

File tree

10 files changed

+96
-2
lines changed

10 files changed

+96
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jspm_packages
3838

3939
# Project Specific
4040
data
41-
docker-compose.override.yml
41+
./docker-compose.override.yml

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ We provide examples of configurations you might use for a specific stack. Each e
8787
* [Mongo](https://github.com/Osedea/nodock/tree/master/_examples/mongo) - MongoDB + Node + NGINX
8888
* [RabbitMQ](https://github.com/Osedea/nodock/tree/master/_examples/rabbitmq) - RabbitMQ + Node + NGINX
8989
* [Memcached](https://github.com/Osedea/nodock/tree/master/_examples/memcached) - Memcached + Node + NGINX
90+
* [RethinkDB](https://github.com/Osedea/nodock/tree/master/_examples/rethinkdb) - RethinkDB + Node + NGINX
9091
* [2 Node Apps](https://github.com/Osedea/nodock/tree/master/_examples/2-nodes) - Node + Node + NGINX
9192
9293
<a name="Workspace"></a>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# docker-compose.override.yml
2+
3+
version: '2'
4+
5+
services:
6+
node2: # name of new container
7+
extends: node # extends the settings from the "node" container
8+
build:
9+
context: ./node
10+
args:
11+
- PROJECT_PATH=second-app
12+
entrypoint: run-nodock "node index.js" # the entrypoint for the "node2" container
13+
nginx:
14+
ports:
15+
- "10000:10000" # the port(s) to forward for the "node2" container
16+
links:
17+
- node2 # link "nginx" to "node2"

_examples/rethinkdb/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## RethinkDB Service
2+
3+
### Setup
4+
5+
Copy the index file in this folder to the project root:
6+
7+
```bash
8+
cd <project_folder>/
9+
10+
cp -r nodock/_examples/rethinkdb/* .
11+
```
12+
13+
### Usage
14+
15+
```bash
16+
cd nodock/
17+
18+
docker-compose up -d node rethinkdb nginx
19+
```
20+
21+
By going to `127.0.0.1` in your browser you should be seeing a nice greeting!
22+
23+
You can access the RethinkDB GUI via `127.0.0.1:28080`.

_examples/rethinkdb/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var express = require('express');
2+
var app = express();
3+
var r = require('rethinkdb');
4+
5+
app.get('/', function(req, res) {
6+
r.connect({
7+
host: 'rethinkdb',
8+
port: 28015,
9+
authKey: '',
10+
}, function(err) {
11+
12+
if (!err) {
13+
res.send('You are amazing');
14+
} else {
15+
res.send('Could not connect to RethinkDB :(');
16+
}
17+
18+
});
19+
});
20+
21+
app.listen(8000);

_examples/rethinkdb/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "example-rethinkdb-node-docker",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "MIT",
11+
"dependencies": {
12+
"express": "^4.14.0",
13+
"rethinkdb": "^2.3.3"
14+
}
15+
}

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ services:
9090
expose:
9191
- "11211"
9292

93+
rethinkdb:
94+
build:
95+
context: ./rethinkdb
96+
volumes:
97+
- ./data/rethinkdb:/data
98+
expose:
99+
- "28015"
100+
- "29015"
101+
ports:
102+
- "28080:8080"
103+
93104
volumes:
94105
image: tianon/true
95106
volumes:

node/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ENV NODE_ENV=$NODE_ENV
1717
RUN groupadd -r www-app &&\
1818
useradd -r -g www-app www-app
1919

20+
RUN mkdir -p /home/www-app &&\
21+
chmod 777 /home/www-app -R
22+
2023
# Install the specified NODE_VERSION or grab latest
2124
RUN n "$NODE_VERSION"
2225

node/scripts/run-nodock.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cd $PROJECT_PATH
1313
if [[ $YARN = true ]]; then
1414
su -c "cd $PROJECT_PATH; yarn" -s /bin/bash www-app
1515
else
16-
su -c "cd $PROJECT_PATH; npm i" -s /bin/bash www-app
16+
su -c "cd $PROJECT_PATH; npm i --force" -s /bin/bash www-app
1717
fi
1818

1919
su -c "cd $PROJECT_PATH; $SCRIPT" -s /bin/bash www-app

rethinkdb/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM rethinkdb
2+
3+
CMD ["rethinkdb", "--bind", "all"]

0 commit comments

Comments
 (0)