File tree Expand file tree Collapse file tree 6 files changed +65
-0
lines changed Expand file tree Collapse file tree 6 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ We provide examples of configurations you might use for a specific stack. Each e
71
71
* [MySQL](https://github.com/Osedea/nodock/tree/master/_examples/mysql) - MySQL + Node + NGINX
72
72
* [Mongo](https://github.com/Osedea/nodock/tree/master/_examples/mongo) - MongoDB + Node + NGINX
73
73
* [RabbitMQ](https://github.com/Osedea/nodock/tree/master/_examples/rabbitmq) - RabbitMQ + Node + NGINX
74
+ * [Memcached](https://github.com/Osedea/nodock/tree/master/_examples/memcached) - Memcached + Node + NGINX
74
75
75
76
<a name="Workspace"></a>
76
77
## Workspace
Original file line number Diff line number Diff line change
1
+ ## Memcached 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 nodock/_examples/memcached/index.js .
11
+ cp nodock/_examples/memcached/package.json .
12
+ ```
13
+
14
+ ### Usage
15
+
16
+ ``` bash
17
+ cd nodock/
18
+
19
+ docker-compose up -d memcached node nginx
20
+ ```
21
+
22
+ By going to ` 127.0.0.1 ` in your browser you should be seeing a message indicating that ` node ` has successfully connected to ` memcached ` .
Original file line number Diff line number Diff line change
1
+ var express = require ( 'express' ) ;
2
+ var app = express ( ) ;
3
+ var Memcached = require ( 'memcached' ) ;
4
+
5
+ app . get ( '/' , function ( req , res ) {
6
+ var memcached = new Memcached ( "memcached:11211" ) ;
7
+ memcached . connect ( 'memcached:11211' , function ( err , conn ) {
8
+ if ( err ) {
9
+ res . send ( 'Could not connect to memcached' ) ;
10
+ } else {
11
+ res . send ( 'Connected to memcached' ) ;
12
+ }
13
+ } ) ;
14
+ } ) ;
15
+
16
+ app . listen ( 8000 ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " example-memcached-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
+ "memcached" : " ^2.2.2"
14
+ }
15
+ }
Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ services:
82
82
volumes_from :
83
83
- volumes
84
84
85
+ memcached :
86
+ build :
87
+ context : ./memcached
88
+ volumes_from :
89
+ - volumes
90
+ expose :
91
+ - " 11211"
92
+
85
93
volumes :
86
94
image : tianon/true
87
95
volumes :
Original file line number Diff line number Diff line change
1
+ FROM memcached:1.4
2
+
3
+ CMD memcached
You can’t perform that action at this time.
0 commit comments