Skip to content

Setting up the development environment

Daniel Hackbarth edited this page Oct 23, 2018 · 50 revisions

Clone repositories

The following repositories are needed:

Set up the development dependencies

  • macOS only: Install Homebrew according to the "Install Homebrew" section at http://brew.sh.

  • Debian only: Install development libraries: sudo apt install cmake libicu-dev

  • Install Ruby:

    • Install chruby according to the chruby homepage. This allows you to have several independent ruby versions installed in your home directory. Do not forget to check the sections on configuration and auto-switching.
    • Install ruby-install according to the ruby-install homepage. This allows you to build ruby versions with chruby.
    • Install ruby by running ruby-install "ruby-$(cat .ruby-version)" in the directory of a ruby-based project (e.g. in ontohub-backend).
    • Install bundler: gem install bundler.
    • Install rubocop linter: gem install rubocop.
    • Optional: Install httpie to get more beautiful JSON output when making HTTP requests from the console. Read their Readme file.
  • Install frontend dependencies (Javascript):

  • Install PostgreSQL and create the databases:

    • Installation
      • macOS: Run brew install postgresql to install it. Then, run brew services start postgresql to start it with every boot. You can disable starting it with every boot with brew services stop postgresql.
      • Arch Linux: sudo pacman -Sy postgresql. To put it in autostart, run sudo systemctl enable postgresql. To remove it from autostart, run sudo systemctl disable postgresql.
      • Ubuntu Linux: sudo apt install postgresql libpq-dev.
    • Debian and Ubuntu: Loosen the super user restrictions such that any user may connect to the database server as the super user: Let the following lines be the only uncommented lines in the /etc/postgresql/X.Y/main/pg_hba.conf
      local   all             all                                     trust
      host    all             all             127.0.0.1/32            trust
      host    all             all             ::1/128                 trust
      
      The first line is the most important line. We have changed peer to trust. Make sure that no line with peer remains. After these changes, run sudo service postgresql restart.
    • All except Ubuntu >= 16.04: Initialize the database directory with initdb /usr/local/var/postgres -E utf8.
      • Debian user need to first login in as root with su (Note: sudo does not work in this case). Then login as the user postgres with su - postgres. Then create the database with /usr/lib/postgresql/X.Y/bin/initdb -E utf8 --locale=en_US.utf8
    • All except Ubuntu >= 16.04 and Debian: Create the database user that is used by Ontohub with createuser -d -w -s postgres.
    • Run bundle to install the dependencies in each directory of the projects
    • Create the development database by running bundle exec rails db:recreate in the ontohub-backend project directory. This database is shared among the different projects.
    • Create the test databases by running RAILS_ENV=test bundle exec rails db:recreate in each directory of the projects (Note: You may need to install subversion and/or git-svn
  • Install RabbitMQ and plugins:

    • RabbitMQ
      • macOS only: Run brew install rabbitmq. To start rabbitmq with every boot, run brew services start rabbitmq. To disable autostart, run brew services stop rabbitmq. If you want to run in manually in the foreground, run rabbitmq-server.
      • Arch Linux: sudo pacman -Sy rabbitmq. To put it in autostart, run sudo systemctl enable rabbitmq. To remove it from autostart, run sudo systemctl disable rabbitmq.
      • Ubuntu Linux: sudo apt install rabbitmq-server
    • Enable the plugin rabbitmq_recent_history_exchange:
      • macOS: /usr/local/opt/rabbitmq/sbin/rabbitmq-plugins enable rabbitmq_recent_history_exchange
      • debian: sudo /usr/sbin/rabbitmq-plugins enable rabbitmq_management sudo /usr/sbin/rabbitmq-plugins enable rabbitmq_recent_history_exchange
      • other systems: rabbitmq-plugins enable rabbitmq_recent_history_exchange
    • Set up the virtual host (for Debian, it is /usr/sbin/rabbitmqctl):
      • sudo rabbitmqctl add_vhost ontohub_development
      • sudo rabbitmqctl set_permissions -p ontohub_development guest ".*" ".*" ".*"
      • Adjust these for a production environment. The default virtual host for the production environment is ontohub.
  • Install Chome/Chromium. This is used for the frontend tests.

  • Install Elasticsearch:

    • macOS: brew install elasticsearch. To put it in autostart, run brew services start elasticsearch. To remove it from autostart, run brew services stop elasticsearch.
    • Arch Linux: sudo pacman -Sy elasticsearch. To put it in autostart, run sudo systemctl enable elasticsearch. To remove it from autostart, run sudo systemctl disable elasticsearch.
    • Ubuntu Linux: Install from APT repository as described on the Elasticsearch installation page.
  • Install Hets-Server (not desktop):

    • macOS: First, obtain the package repository with brew tap spechub/hets and then, install Hets with brew install hets-server.
    • Arch Linux: Install hets-server from the AUR.
    • Ubuntu Linux: Run sudo apt install hets-server.

Initialize backend repository

To use the local repository of our gems, run the following commands:

bundle config --local local.ontohub-models <absolute path to the ontohub-models repository>
bundle config --local local.index <absolute path to the index repository>
bundle config --local local.bringit <absolute path to the bringit repository>
bundle config --local local.graphql-pundit <absolute path to the graphql-pundit repository>

In each repository (except ontohub-frontend), starting with ontohub-models, run the following command to install all the dependencies:

bundle

Configure the global yarn package directory

By default, yarn uses the same directories, that npm uses. This usually means that root is required to install new packages. You can change the install path to e.g. ~/.npm-packages by running the following commands:

mkdir "$HOME/.npm-packages"
echo 'NPM_PACKAGES="$HOME/.npm-packages"' >> ~/.bashrc # or ~/.zshrc
echo 'PATH="$PATH:$NPM_PACKAGES/bin"' >> ~/.bashrc # or ~/.zshrc
echo 'prefix=${HOME}/.npm-packages' >> ~/.npmrc

Initialize frontend repository

Run the following commands in the frontend repository:

Restart your shell and run the following commands in the frontend repository directory:

yarn # install dependencies

To start the frontend, run yarn start.