Skip to content

Instantly share code, notes, and snippets.

@uladkasach
Created June 8, 2017 23:13
Show Gist options
  • Save uladkasach/0510a5459542add7fd56416a5776a59f to your computer and use it in GitHub Desktop.
Save uladkasach/0510a5459542add7fd56416a5776a59f to your computer and use it in GitHub Desktop.
Run OpenHIM with vagrant

Run OpenHIM with Vagrant

  • https://github.com/jembi/openhim-core-js/wiki/Running-the-OpenHIM-using-Vagrant
  • setup core vagrant
    • cd /var/www/git/Regenstrief/OHIE/certificate_renewal/ohim
    • mkdir core; cd core;
    • vagrant init ubuntu/trusty64;
    • set provisioner
      • Create the provisioner file:
      cat > provision_ohim_core.sh <<EOF  
      ## based on instructions found at http://openhim.readthedocs.io/en/latest/getting-started.html#installing-the-openhim-core
      echo "Begin provisioning of provision_ohim_core.sh..."  
      
      ## Install Node.js, https://nodejs.org/en/download/package-manager/
      #mkdir -p /etc/puppet/modules;
      #puppet module install willdurand/nodejs
      curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
      sudo apt-get install -y nodejs  build-essential
      
      ## Install MongoDB, https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04
      sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927;
      echo 'deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list;
      sudo apt-get update;
      sudo apt-get install -y mongodb-org;
      sudo service mongodb start
      
      ## Install git
      sudo apt-get -y install git
      
      ## Install the OpenHIM-core package globally
      sudo npm install openhim-core -g
      
      echo "Provisioning of provision_ohim_core.sh completed. [Success]."
      EOF
      
      • Create the virual machine config file:
      cat > virtual_machine_config.txt <<EOF
      # Configure Virtual Machine\n
      config.vm.provider "virtualbox" do |v|\n
          v.customize ["modifyvm", :id, "--memory", 1536]\n
      end\n
      EOF
      
      • Create the port forwarding config file:
      cat > port_forwarding.txt <<EOF
      # Configure port forwarding\n
      config.vm.network "forwarded_port", guest: 5000, host: 5000\n
      config.vm.network "forwarded_port", guest: 5001, host: 5001\n
      config.vm.network "forwarded_port", guest: 5050, host: 5050\n
      config.vm.network "forwarded_port", guest: 5051, host: 5051\n
      config.vm.network "forwarded_port", guest: 5052, host: 5052\n
      config.vm.network "forwarded_port", guest: 8080, host: 8080\n
      EOF
      
      • Add configs and provisioners to the Vagrant file, before the last line
        contents=$(cat virtual_machine_config.txt); sed -i '$i'"$(echo $contents)" Vagrantfile;
        contents=$(cat port_forwarding.txt); sed -i '$i'"$(echo $contents)" Vagrantfile;
        sed -i '$i'"$(echo 'config.vm.provision "shell", path: "provision_ohim_core.sh"')" Vagrantfile;
        
    • Start the vagrant
      • vagrant up --provider virtualbox
    • Start the server
      • openhim-core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment