Skip to content

Commit

Permalink
Added redis service (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
philtrep authored Feb 14, 2018
1 parent 42d0264 commit cb0c279
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![NoDock](https://raw.githubusercontent.com/Osedea/nodock/master/docs/images/logo.png)

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

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

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

version: '2'
version: '3'

services:
[...]
Expand All @@ -88,6 +89,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
* [Redis](https://github.com/Osedea/nodock/tree/master/_examples/redis) - Redis + 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
Expand Down Expand Up @@ -339,6 +341,10 @@ To activate them, change their values to `true` in your docker-compose file:
- RABBITMQ_DEFAULT_USER=custom_user
- RABBITMQ_DEFAULT_PASS=custom_pass
```
<a name="Modify-Redis-Config"></a>
#### Modify the Redis config
You can edit `redis/redis.conf` to modify the redis config.

<a name="Contributing"></a>
## Contributing
Do not hesitate to contribute to NoDock by creating an issue, fixing a bug or bringing a new idea to the table.
Expand Down
21 changes: 21 additions & 0 deletions _examples/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Redis Service

### Setup

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

```bash
cd <project_folder>/

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

### Usage

```bash
cd nodock/

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

By going to `127.0.0.1` in your browser you should be seeing a message indicating that `node` has successfully connected to `redis`.
21 changes: 21 additions & 0 deletions _examples/redis/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var express = require('express');
var app = express();
var redis = require("redis");


app.get('/', function(req, res) {
var client = redis.createClient({
host: 'redis',
port: '6379'
});

client.on("error", function (err) {
res.send('Could not connect to redis');
});

client.on('connect', function() {
res.send('Connected to redis');
});
});

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

redis:
build:
context: ./redis
expose:
- "6379"
volumes:
- ./data/redis:/data

rethinkdb:
build:
context: ./rethinkdb
Expand Down
5 changes: 5 additions & 0 deletions redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM redis:4.0

COPY redis.conf /usr/local/etc/redis/redis.conf

CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
48 changes: 48 additions & 0 deletions redis/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
daemonize no
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile ""
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

0 comments on commit cb0c279

Please sign in to comment.