Hevicado is an application for office and schedule management for doctors and small organizations.
Generic:
- Docker: 1.6.0 or newer
- Ansible: 1.9.0.1 or newer
- Vagrant: for local development
Backend:
- Scala: 2.10.3
- Sbt: 0.13:6
- MongoDB: 3.0.0 or newer
Frontend:
- npm
- bower
- gulp
*** Note: *** Use shorcut run-be.sh script to do bellow steps.
*** Note: *** MongoDB must be up and running in order to make local development.
- Go to backend
cd be
- Run sbt
sbt
Once it's up, similar message will be displayed:
hevicado:master...origin/master:1.0.0>
- Chose web project
hevicado:master...origin/master:1.0.0> project io-web
- Run web project locally
web:master...origin/master:1.0.0> run
or for running with auto-refresh mode:
web:master...origin/master:1.0.0> ~re-start
After that server will be run at port 8000
4*) Demo data usage
Demo directory of project contains:
a) Project for Postman plugin (postman.json) which holds API with sample calls that can be made to back-end
b) Sample data that can be imported into hevicadoDB
c) Rest API in Postman can be imported from: https://www.getpostman.com/collections/ae766dcb9ce1d95aeb7a
***Note: *** Use shorcut run-fe.sh script to do bellow steps.
- Go to frontend
cd fe
- Install dependencies
$npm install
- Run unit tests
$npm test
or
gulp test
- Run e2e tests
$npm start
$npm run protractor
- Run application locally
$npm start
or run using gulp for browser auto-refreshing:
$gulp
Hevicado's environments are managed using Ansible. All tasks are automated and can be run at any time.
- Provision server with needed packages:
ansible-playbook -i {{env}} provisioning/site.yml
- Build packages:
sudo build.sh
Note: since build prepares Docker images, root privileges are required
- Deploy all:
ansible-playbook -i {{env}} deployment/site.yml --vault-password-file ~/.hevicado_vault.txt
Hevicado has monitoring prepared that is tracing:
-
access logs
-
loadbalancer
-
hevicado modules: mongo, backend, frontend
Monitoring is done using ELK stack (elasticsearch-logstash-kibana) and Zabbix.
- Go to monitoring project
cd monitoring/anible
- Provision monitoring with needed packages:
ansible-playbook -i {{env}} provisioning/site.yml
- Deploy all to monitoring cluster:
ansible-playbook -i {{env}} deployment/site.yml --vault-password-file ~/.hevicado_vault.txt
Note: Project contains all needed certificates. This section is valid in case some certificate expires.
- Set up IP in v3_ca in /etc/ssl/openssl.cnf or provide separate config where it's set
[ v3_ca ]
subjectAltName = IP:{ node_ip }
- Generate certificate
openssl req -x509 -batch -nodes -newkey rsa:2048 -keyout dev.key -out dev.crt -days 999
Local environment can be created with any number of nodes using vagrant.
If vagrant is started with provisioning (--provision parameter) then provisioning and deployment is triggered thus all services will be started automatically on VMs.
- Start VMs for hevicado
vagrant up --provision
- Stop VMs for hevicado
vagrant halt
- Go to monitoring:
cd monitoring
- Start VMs for monitoring
vagrant up --provision
- Stop VMs for monitoring
vagrant halt
- Check communication with zabbix aggent
zabbix_get -s <host_ip> -p 10050 -k "system.cpu.load[all,avg1]"
- Ping
ansible all -i {{env}} -m ping
- Run a command on all servers
ansible all -i {{env}} -a "whoami"
ansible all -i {{env}} -a "uptime"
ansible all -i {{env}} -a "date"
ansible all -i {{env}} -a "cat /etc/issue"
ansible all -i {{env}} -l hevi-dev -a "docker ps"
- Show memory, cpu and other config options on all servers
ansible all -i {{env}} -m setup
ansible all -i {{env}} -m setup -a "filter=ansible_*_mb"
ansible all -i {{env}} -m setup -a "filter=ansible_processor*"
ansible all -i {{env}} -m setup -a "filter=ansible_all_ipv4_addresses"
ansible all -i {{env}} -m setup -a "filter=ansible_bios_*"
- Run playbook
ansible-playbook -i {{env}} deployment.yml --ask-sudo-pass
ansible-playbook -i {{env}} deployment.yml --tags backend --ask-sudo-pass
- Dry-run, i.e. only check and report what changes should be made without actually executing them
ansible-playbook -i {{env}} deployment.yml --tags "mongo" --ask-sudo-pass --check
ansible-playbook -i {{env}} deployment.yml --tags "backend" --ask-sudo-pass --check --diff
Hevicado server works in a Docker container, in order to run hevicado on Docker one needs to:
Note: CM is automated using Ansible. You don't have to run docker manually. See Ansible section for more details.
- List local docker images, the output should contain mongo and hevicado/server images:
docker images
- List runnning containers:
docker ps
Congratulations, after those steps hevicado/server works in a dockerized environment.
- Stop a container:
docker stop CONTAINER_ID / CONTAINER_NAME
- Remove all stopped containers:
docker rm $(docker ps -a -q)
- Remove all images issue:
docker rmi $(docker images -q)
- Attach to a running container
docker exec -it CONTAINER_NAME bash
- Build hevicado-server docker image:
Note: hevicado package must be built first
docker build -t hevicado-be .
- Run hevicado/server container in detached mode using docker, set the name of the container to webXX, link hevicado/server to mongodb01 container, map port 8000 to local port 80XX, map ./docker/workdir docker volume:
cd ./docker/workdir
docker run -d -P --name web01 --link mongodb01:mongodb01 -p 8001:8000 -v $PWD:/usr/share/hevicado -t hevicado/server:latest
docker run -d -P --name web02 --link mongodb01:mongodb01 -p 8002:8000 -v $PWD:/usr/share/hevicado -t hevicado/server:latest
..
docker run -d -P --name webXX --link mongodb01:mongodb01 -p 80XX:8000 -v $PWD:/usr/share/hevicado -t hevicado/server:latest
- Download official MongoDB docker image:
docker pull mongo:latest
- Run MongoDB container in detached mode using docker, set the name of the container to: mongodb01, define mongo db directory (here we map the current directory), map port 27017 locally
docker run -d --name mongodb01 -v $PWD:/data/db -p 27017:27017 -t mongo
- Download official Nginx docker image:
docker pull nginx:latest
- Run Nginx in a docker container
docker run -d --name nginx -p 80:80 -p 443:443 -v /usr/share/nginx/html:/usr/share/nginx/html:ro -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro -t nginx