Skip to content

Commit cb0c279

Browse files
authored
Added redis service (#91)
1 parent 42d0264 commit cb0c279

File tree

7 files changed

+126
-2
lines changed

7 files changed

+126
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![NoDock](https://raw.githubusercontent.com/Osedea/nodock/master/docs/images/logo.png)
22

3-
Docker Compose for Node projects with Node, MySQL, MongoDB, NGINX, Memcached, Certbot and RabbitMQ images
3+
Docker Compose for Node projects with Node, MySQL, MongoDB, NGINX, Memcached, Redis, Certbot and RabbitMQ images
44

55
![Node + Docker](https://raw.githubusercontent.com/Osedea/nodock/master/docs/images/nodock.jpg)
66

@@ -36,6 +36,7 @@ You can use NoDock for simple projects by using one of the [examples](#Examples)
3636
- [Change the timezone](#Change-the-timezone)
3737
- [Use RabbitMQ plugins](#Use-RabbitMQ-plugins)
3838
- [Change the RabbitMQ user/password](#Change-RabbitMQ-User)
39+
- [Modify Redis config](#Modify-Redis-Config)
3940
- [Contributing](#Contributing)
4041
- [License](#License)
4142
- [Credits](#credits)
@@ -73,7 +74,7 @@ To overwrite the `docker-compose.yml` file you can use a `docker-compose.overrid
7374
```yaml
7475
# docker-compose.override.yml
7576

76-
version: '2'
77+
version: '3'
7778

7879
services:
7980
[...]
@@ -88,6 +89,7 @@ We provide examples of configurations you might use for a specific stack. Each e
8889
* [Mongo](https://github.com/Osedea/nodock/tree/master/_examples/mongo) - MongoDB + Node + NGINX
8990
* [RabbitMQ](https://github.com/Osedea/nodock/tree/master/_examples/rabbitmq) - RabbitMQ + Node + NGINX
9091
* [Memcached](https://github.com/Osedea/nodock/tree/master/_examples/memcached) - Memcached + Node + NGINX
92+
* [Redis](https://github.com/Osedea/nodock/tree/master/_examples/redis) - Redis + Node + NGINX
9193
* [RethinkDB](https://github.com/Osedea/nodock/tree/master/_examples/rethinkdb) - RethinkDB + Node + NGINX
9294
* [2 Node Apps](https://github.com/Osedea/nodock/tree/master/_examples/2-nodes) - Node + Node + NGINX
9395
@@ -339,6 +341,10 @@ To activate them, change their values to `true` in your docker-compose file:
339341
- RABBITMQ_DEFAULT_USER=custom_user
340342
- RABBITMQ_DEFAULT_PASS=custom_pass
341343
```
344+
<a name="Modify-Redis-Config"></a>
345+
#### Modify the Redis config
346+
You can edit `redis/redis.conf` to modify the redis config.
347+
342348
<a name="Contributing"></a>
343349
## Contributing
344350
Do not hesitate to contribute to NoDock by creating an issue, fixing a bug or bringing a new idea to the table.

_examples/redis/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Redis 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/redis/* .
11+
```
12+
13+
### Usage
14+
15+
```bash
16+
cd nodock/
17+
18+
docker-compose up -d redis node nginx
19+
```
20+
21+
By going to `127.0.0.1` in your browser you should be seeing a message indicating that `node` has successfully connected to `redis`.

_examples/redis/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 redis = require("redis");
4+
5+
6+
app.get('/', function(req, res) {
7+
var client = redis.createClient({
8+
host: 'redis',
9+
port: '6379'
10+
});
11+
12+
client.on("error", function (err) {
13+
res.send('Could not connect to redis');
14+
});
15+
16+
client.on('connect', function() {
17+
res.send('Connected to redis');
18+
});
19+
});
20+
21+
app.listen(8000);

_examples/redis/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "example-redis-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+
"redis": "^2.8.0"
14+
}
15+
}

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ services:
105105
expose:
106106
- "11211"
107107

108+
redis:
109+
build:
110+
context: ./redis
111+
expose:
112+
- "6379"
113+
volumes:
114+
- ./data/redis:/data
115+
108116
rethinkdb:
109117
build:
110118
context: ./rethinkdb

redis/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM redis:4.0
2+
3+
COPY redis.conf /usr/local/etc/redis/redis.conf
4+
5+
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

redis/redis.conf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
daemonize no
2+
pidfile /var/run/redis.pid
3+
port 6379
4+
tcp-backlog 511
5+
timeout 0
6+
tcp-keepalive 0
7+
loglevel notice
8+
logfile ""
9+
databases 16
10+
save 900 1
11+
save 300 10
12+
save 60 10000
13+
stop-writes-on-bgsave-error yes
14+
rdbcompression yes
15+
rdbchecksum yes
16+
dbfilename dump.rdb
17+
slave-serve-stale-data yes
18+
slave-read-only yes
19+
repl-diskless-sync no
20+
repl-diskless-sync-delay 5
21+
repl-disable-tcp-nodelay no
22+
slave-priority 100
23+
appendonly no
24+
appendfilename "appendonly.aof"
25+
appendfsync everysec
26+
no-appendfsync-on-rewrite no
27+
auto-aof-rewrite-percentage 100
28+
auto-aof-rewrite-min-size 64mb
29+
aof-load-truncated yes
30+
lua-time-limit 5000
31+
slowlog-log-slower-than 10000
32+
slowlog-max-len 128
33+
latency-monitor-threshold 0
34+
notify-keyspace-events ""
35+
hash-max-ziplist-entries 512
36+
hash-max-ziplist-value 64
37+
list-max-ziplist-entries 512
38+
list-max-ziplist-value 64
39+
set-max-intset-entries 512
40+
zset-max-ziplist-entries 128
41+
zset-max-ziplist-value 64
42+
hll-sparse-max-bytes 3000
43+
activerehashing yes
44+
client-output-buffer-limit normal 0 0 0
45+
client-output-buffer-limit slave 256mb 64mb 60
46+
client-output-buffer-limit pubsub 32mb 8mb 60
47+
hz 10
48+
aof-rewrite-incremental-fsync yes

0 commit comments

Comments
 (0)