herolynx / hevicado

Hevicado - doctors' office

Home Page:https://hevicado.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hevicado Circle CI

Hevicado is an application for office and schedule management for doctors and small organizations.

Required

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

Backend

*** Note: *** Use shorcut run-be.sh script to do bellow steps.

*** Note: *** MongoDB must be up and running in order to make local development.

  1. Go to backend
cd be
  1. Run sbt
    sbt

Once it's up, similar message will be displayed:

hevicado:master...origin/master:1.0.0>
  1. Chose web project
hevicado:master...origin/master:1.0.0> project io-web
  1. 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

Frontend

***Note: *** Use shorcut run-fe.sh script to do bellow steps.

  1. Go to frontend
cd fe
  1. Install dependencies
   $npm install
  1. Run unit tests
   $npm test

or

   gulp test
  1. Run e2e tests
   $npm start
   $npm run protractor
  1. Run application locally
   $npm start

or run using gulp for browser auto-refreshing:

   $gulp

Build & deployment

Hevicado's environments are managed using Ansible. All tasks are automated and can be run at any time.

  1. Provision server with needed packages:
ansible-playbook -i {{env}} provisioning/site.yml
  1. Build packages:
sudo build.sh

Note: since build prepares Docker images, root privileges are required

  1. Deploy all:
ansible-playbook -i {{env}} deployment/site.yml --vault-password-file ~/.hevicado_vault.txt

Monitoring

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.

Monitoring build & deployment
  1. Go to monitoring project
cd monitoring/anible
  1. Provision monitoring with needed packages:
ansible-playbook -i {{env}} provisioning/site.yml
  1. Deploy all to monitoring cluster:
ansible-playbook -i {{env}} deployment/site.yml --vault-password-file ~/.hevicado_vault.txt
Generating self-signed certificate:

Note: Project contains all needed certificates. This section is valid in case some certificate expires.

  1. 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 }
  1. Generate certificate

openssl req -x509 -batch -nodes -newkey rsa:2048 -keyout dev.key -out dev.crt -days 999

Local environment

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.

Local hevicado application
  1. Start VMs for hevicado
vagrant up --provision
  1. Stop VMs for hevicado
vagrant halt
Local monitoring
  1. Go to monitoring:
cd monitoring
  1. Start VMs for monitoring
vagrant up --provision
  1. Stop VMs for monitoring
vagrant halt

Other

Zabbix

Zabbix - common commands
  1. Check communication with zabbix aggent
zabbix_get -s <host_ip> -p 10050 -k "system.cpu.load[all,avg1]"

Ansible

Ansible - common commands
  1. Ping
ansible all -i {{env}} -m ping
  1. 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"
  1. 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_*"
  1. Run playbook
ansible-playbook -i {{env}} deployment.yml --ask-sudo-pass
ansible-playbook -i {{env}} deployment.yml --tags backend --ask-sudo-pass
  1. 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

Docker

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.

Docker - common commands
  1. List local docker images, the output should contain mongo and hevicado/server images:
docker images
  1. List runnning containers:
docker ps

Congratulations, after those steps hevicado/server works in a dockerized environment.

  1. Stop a container:
docker stop CONTAINER_ID / CONTAINER_NAME
  1. Remove all stopped containers:
docker rm $(docker ps -a -q)
  1. Remove all images issue:
docker rmi $(docker images -q)
  1. Attach to a running container
docker exec -it CONTAINER_NAME bash
Docker - Hevicado
  1. Build hevicado-server docker image:

Note: hevicado package must be built first

docker build -t hevicado-be .
  1. 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
Docker - MongoDB
  1. Download official MongoDB docker image:
docker pull mongo:latest
  1. 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
Docker - Nginx
  1. Download official Nginx docker image:
docker pull nginx:latest
  1. 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

About

Hevicado - doctors' office

https://hevicado.com

License:MIT License


Languages

Language:JavaScript 42.7%Language:CSS 28.6%Language:Scala 19.3%Language:HTML 8.0%Language:Shell 1.1%Language:Ruby 0.1%Language:Nginx 0.0%Language:Perl 6 0.0%Language:Perl 0.0%