Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11 from Dulce-Work-Schedule/3_4_5_7_Inicial
Browse files Browse the repository at this point in the history
Fix #3 #4 #5 #7 Arrumando ambiente do docker.
  • Loading branch information
alvesisaque authored May 30, 2018
2 parents 79a7edb + a198889 commit a6183f5
Show file tree
Hide file tree
Showing 24 changed files with 257 additions and 137 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ buck-out/
# project
package-lock.json
coverage/
.coveralls.yml
**coveralls.env
**.nyc_output/

# fastlane
#
Expand Down
57 changes: 15 additions & 42 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
sudo: required
language: node_js
services:
- docker
node_js:
- "8"
cache:
directories:
- "node_modules"
script:
- npm install -g
- npm run lint
matrix:
include:
- language: node_js
os: linux
install:

before_install:
- sudo apt-get remove docker docker-engine docker.io
- sudo apt-get update
- sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get install docker-ce
- docker-compose version
- docker version

before_script:
- cd $TRAVIS_BUILD_DIR/Database
- sudo docker-compose up --build -d&
- cd $TRAVIS_BUILD_DIR/RabbitMQ
- sudo docker-compose up --build -d&
- cd $TRAVIS_BUILD_DIR/User
- sudo docker-compose up --build -d&
- cd $TRAVIS_BUILD_DIR/Login
- sudo docker-compose up --build -d&
env:
- DOCKER_COMPOSE_VERSION=1.21.0
services:
- docker

env:
- DOCKER_COMPOSE_VERSION=1.21.0
before_install:
- sudo curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
- docker-compose version
- docker version
before_script:
- ./utils/script_coveralls.sh
- cd $TRAVIS_BUILD_DIR/Docker/Test
- sudo docker-compose -f build.yml build

script:
- cd $TRAVIS_BUILD_DIR/Login
- sudo docker-compose run loginserver npm run test
script:
- sudo docker-compose -f start-sector.yml run sectorserver npm run coverage
13 changes: 0 additions & 13 deletions Client/Dockerfile

This file was deleted.

16 changes: 8 additions & 8 deletions Client/client_sector.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ var seneca = require('seneca')()
.use('seneca-amqp-transport')
.use("entity")
.use('api')
.client( {
type:'amqp',
pin:'role:sector',
port: 5672,
username: 'guest',
password: 'guest',
url: 'amqp://rabbitmq',
} )
.client({
type: 'amqp',
pin: 'role:sector',
port: process.env.RABBITMQ_PORT,
username: process.env.RABBITMQ_DEFAULT_USER,
password: process.env.RABBITMQ_DEFAULT_PASS,
url: 'amqp://' + process.env.RABBITMQ_HOST
})
.ready(() => {
app.listen(8080)
})
11 changes: 11 additions & 0 deletions Docker/Dev/Client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM dulce/dulce:base-dev

COPY Client/package.json /usr/src/app/package.json

RUN npm install --development

ADD Client/ /usr/src/app

EXPOSE 8080

CMD ["npm", "start"]
11 changes: 11 additions & 0 deletions Docker/Dev/Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM dulce/dulce:base-dev

COPY Server/package.json /usr/src/app/package.json

RUN npm install --development

ADD Server/ /usr/src/app

EXPOSE 8080

CMD ["npm", "start"]
14 changes: 14 additions & 0 deletions Docker/Dev/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.5'

services:
sectorserver:
image: dulce/sector-server:dev
build:
context: ../../
dockerfile: Docker/Dev/Server/Dockerfile

sectorclient:
image: dulce/sector-client:dev
build:
context: ../../
dockerfile: Docker/Dev/Client/Dockerfile
3 changes: 3 additions & 0 deletions Docker/Dev/env/mongo.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MONGO_DATABASE=dataBaseSectors
MONGO_HOST=sectormongo
MONGO_PORT=27017
5 changes: 5 additions & 0 deletions Docker/Dev/env/rabbitmq.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RABBITMQ_DEFAULT_USER=dulce
RABBITMQ_DEFAULT_PASS=dulce

RABBITMQ_HOST=sectorrabbitmq
RABBITMQ_PORT=5672
32 changes: 32 additions & 0 deletions Docker/Dev/start-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.5'

services:
sectormongo:
image: mongo
env_file:
- ./env/mongo.env
networks:
- dulce-db
ports:
- 27017
volumes:
- db_data:/data/db

sectorrabbitmq:
image: rabbitmq:3.6.14-management
env_file:
- ./env/rabbitmq.env
ports:
- 5672:5672
- 15672:15672
networks:
- dulce-rabbitmq

networks:
dulce-db:
name: dulce-db
dulce-rabbitmq:
name: dulce-rabbitmq

volumes:
db_data: {}
36 changes: 36 additions & 0 deletions Docker/Dev/start-sector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.5'

services:
sectorserver:
image: dulce/sector-server:dev
restart: always
env_file:
- ./env/mongo.env
- ./env/rabbitmq.env
ports:
- 8080:8080
volumes:
- ../../Server:/usr/src/app
- /usr/src/app/node_modules
networks:
- dulce-db
- dulce-rabbitmq

sectorclient:
image: dulce/sector-client:dev
restart: always
env_file:
- ./env/rabbitmq.env
ports:
- 8083:8080
volumes:
- ../../Client:/usr/src/app
- /usr/src/app/node_modules
networks:
- dulce-rabbitmq

networks:
dulce-db:
name: dulce-db
dulce-rabbitmq:
name: dulce-rabbitmq
Empty file added Docker/Prod/.keep
Empty file.
11 changes: 11 additions & 0 deletions Docker/Test/Client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM dulce/dulce:base-dev

COPY Client/package.json /usr/src/app/package.json

RUN npm i -g npm
RUN npm install --development
ADD Client/ /usr/src/app/

EXPOSE 8080

CMD ["npm","start"]
11 changes: 11 additions & 0 deletions Docker/Test/Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM dulce/dulce:base-dev

WORKDIR /usr/src/app

ADD Server/package.json /usr/src/app/

RUN npm install

ADD Server /usr/src/app

CMD ["npm", "run", "coverage"]
14 changes: 14 additions & 0 deletions Docker/Test/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.5'

services:
sectorserver:
image: dulce/sector-server:test
build:
context: ../../
dockerfile: Docker/Test/Server/Dockerfile

sectorclient:
image: dulce/sector-client:test
build:
context: ../../
dockerfile: Docker/Test/Client/Dockerfile
Empty file added Docker/Test/env/.keep
Empty file.
13 changes: 13 additions & 0 deletions Docker/Test/start-sector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.5'

services:
sectorserver:
image: dulce/sector-server:test
restart: always
env_file:
- ./env/coveralls.env
ports:
- 8080:8080
volumes:
- ../../Server:/usr/src/app
- /usr/src/app/node_modules
13 changes: 0 additions & 13 deletions Server/Dockerfile

This file was deleted.

22 changes: 22 additions & 0 deletions Server/_sector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = function(options){

this.add('role:sector,cmd:create', function create (msg,respond) {
var sector = this.make('sectors')
sector.name = msg.name
sector.save$(function(err,sector){
respond(null,sector)
})
})

this.add('role:sector, cmd:listSector', function listSector(msg, respond){
var sector = this.make('sectors');
sector.list$({all$:true}, function(error,sector){
respond(null,sector);
});
})

this.add('role:sector, cmd:error', function error(msg, respond){
respond(null, {success:false, message: 'acesso negado'});
})

}
11 changes: 8 additions & 3 deletions Server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
"main": "app.js",
"scripts": {
"start": "nodemon sector.js",
"test": "./node_modules/.bin/mocha --reporter spec"
"test": "nyc --reporter=html --reporter=text mocha",
"coverage": "npm run cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"cover": "istanbul cover _mocha"
},
"author": "",
"license": "MIT",
"dependencies": {
"bcrypt": "^1.0.3",
"bcrypt": "2.0.1",
"body-parser": "1.15.2",
"chai": "^4.1.2",
"express": "^4.14.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^4.6.1",
Expand All @@ -25,9 +28,11 @@
"seneca-web-adapter-express": "^1.1.1"
},
"devDependencies": {
"coveralls": "^3.0.1",
"istanbul": "^0.4.5",
"jest": "^22.4.3",
"mocha": "^5.0.5",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^11.7.3",
"should": "^13.2.1",
"supertest": "^3.0.0"
}
Expand Down
34 changes: 8 additions & 26 deletions Server/sector.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
require('seneca')()
.use("entity")
.use('mongo-store',{
name:'dataBaseHospitals',
host:'mongo',
port:27017
name: process.env.MONGO_DATABASE,
host:process.env.MONGO_HOST,
port: process.env.MONGO_PORT
})
.use('seneca-amqp-transport')
.use('_sector')
.listen({
type:'amqp',
pin:'role:sector',
port: 5672,
username: 'guest',
password: 'guest',
url: 'amqp://rabbitmq',
port: process.env.RABBITMQ_PORT,
username: process.env.RABBITMQ_DEFAULT_USER,
password: process.env.RABBITMQ_DEFAULT_PASS,
url: 'amqp://'+ process.env.RABBITMQ_HOST
})

.add('role:sector,cmd:create', function create (msg,respond) {
var sector = this.make('sectors')
sector.name = msg.name
sector.save$(function(err,sector){
respond(null,sector)
})
})

.add('role:sector, cmd:listSector', function listSector(msg, respond){
var sector = this.make('sectors');
sector.list$({all$:true}, function(error,sector){
respond(null,sector);
});
})

.add('role:sector, cmd:error', function error(msg, respond){
respond(null, {success:false, message: 'acesso negado'});
})
Loading

0 comments on commit a6183f5

Please sign in to comment.