Skip to content

Commit

Permalink
Merge pull request #61 from philtrep/memcached
Browse files Browse the repository at this point in the history
Added memcached
  • Loading branch information
philtrep authored Oct 19, 2016
2 parents 7aeff8f + 86a4719 commit ae56313
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ We provide examples of configurations you might use for a specific stack. Each e
* [MySQL](https://github.com/Osedea/nodock/tree/master/_examples/mysql) - MySQL + Node + NGINX
* [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
<a name="Workspace"></a>
## Workspace
Expand Down
22 changes: 22 additions & 0 deletions _examples/memcached/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Memcached Service

### Setup

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

```bash
cd <project_folder>/

cp nodock/_examples/memcached/index.js .
cp nodock/_examples/memcached/package.json .
```

### Usage

```bash
cd nodock/

docker-compose up -d memcached 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 `memcached`.
16 changes: 16 additions & 0 deletions _examples/memcached/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var express = require('express');
var app = express();
var Memcached = require('memcached');

app.get('/', function(req, res) {
var memcached = new Memcached("memcached:11211");
memcached.connect('memcached:11211', function( err, conn ){
if( err ) {
res.send('Could not connect to memcached');
} else {
res.send('Connected to memcached');
}
});
});

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

memcached:
build:
context: ./memcached
volumes_from:
- volumes
expose:
- "11211"

volumes:
image: tianon/true
volumes:
Expand Down
3 changes: 3 additions & 0 deletions memcached/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM memcached:1.4

CMD memcached

0 comments on commit ae56313

Please sign in to comment.