├── .gitignore ├── Makefile ├── README.md ├── app ├── .gitignore ├── app.js ├── package.json └── view │ └── index.html ├── db ├── .gitignore └── dbms │ └── auth └── docker-compose.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.log 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: demo 2 | 3 | ## application 4 | demo: setup reload 5 | 6 | dev: setup 7 | nodemon -x "make reload" 8 | 9 | setup: 10 | docker-compose run --rm --entrypoint "npm install" app 11 | 12 | console: 13 | docker-compose run --rm --entrypoint bash app 14 | 15 | reload: rm 16 | docker-compose up app 17 | 18 | rm: 19 | docker-compose kill app && docker-compose rm --force --all app 20 | 21 | stop: 22 | docker-compose stop --timeout 3 23 | 24 | up: 25 | docker-compose up -d app 26 | 27 | ## docker aliases 28 | ps: 29 | docker-compose ps 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Neo4j + docker + docker-compose + node.js example 2 | 3 | ## how to start 4 | just make it: 5 | - run terminal 6 | - `$ make` 7 | 8 | ### dependencies: 9 | - `make` 10 | - `docker` [https://www.docker.com/products/docker-engine](https://www.docker.com/products/docker-engine) 11 | - `docker-compose` [https://docs.docker.com/compose/](https://docs.docker.com/compose/) 12 | 13 | ### docker.host 14 | It depends on platform: 15 | - OSX: please check `docker-machine ip` 16 | - Linux: `127.0.0.1` or `localhost` 17 | 18 | ### neo4j 19 | It binds to port `docker.host:17474` [http://docker.host:17474/](http://docker.host:17474/) This is web interface to db. 20 | - Login: `neo4j` 21 | - Password: `test` 22 | 23 | ### app 24 | It binds to port `docker.host:13000` [http://docker.host:13000/](http://docker.host:13000/) 25 | There are AngularJS/Bootstrap the simplest client for example. Just click `load` button. 26 | 27 | #### Files 28 | Please check files to clarify concepts 29 | - [docker-compose.yml](docker-compose.yml) services configuration 30 | - [Makefile](Makefile) helper to manage 31 | - [app.js](./app/app.js) the simplest node.js app 32 | - [index.html](./app/view/index.html) the simplest AngularJS app 33 | 34 | #### Have a fun! 35 | Use microservice and have a fun! 36 | Best regards [+1G Team](http://plus1generation.com/) and [slava hatnuke](https://ua.linkedin.com/in/slavahatnuke) 37 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /app/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | 4 | var neo4j = require('node-neo4j'); 5 | var db = new neo4j('http://neo4j:test@neo4j:7474'); 6 | 7 | app.use('/', express.static(__dirname + '/view')); 8 | 9 | app.get('/tools/load', function (req, res, next) { 10 | db.insertNode({ 11 | name: 'Darth Vader #' + parseInt(Math.random() * 100), 12 | sex: 'male' 13 | }, ['Person'], function (err, node) { 14 | if (err) return next(err); 15 | 16 | res.json(node); 17 | }); 18 | }); 19 | 20 | app.get('/tools/drop', function (req, res, next) { 21 | db.cypherQuery("MATCH (n) DETACH DELETE n", function (err, result) { 22 | if (err) return next(err); 23 | res.json(result); 24 | }); 25 | }); 26 | 27 | app.get('/persons', function (req, res, next) { 28 | db.cypherQuery("MATCH (person:Person) RETURN person", function (err, result) { 29 | if (err) return next(err); 30 | res.json(result.data); 31 | }); 32 | }); 33 | 34 | 35 | app.listen(3000, function () { 36 | console.log('started'); 37 | }); -------------------------------------------------------------------------------- /app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "express": "^4.13.4", 13 | "node-neo4j": "^2.0.3" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/view/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |