Skip to content

Setting up the development environment

Eugen Kuksa edited this page Oct 2, 2017 · 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-get 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.
    • 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 beatuiful 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-get install postgresql libpq-dev.
    • Debian only: 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.
    • Initialize the database directory with initdb /usr/local/var/postgres -E utf8.
    • Create the database user that is used by Ontohub with createuser -d -w -s postgres.
    • Create the development database by running rails db:create && rails db:migrate in the ontohub-backend project directory. This database is shared among the different projects.
    • Create the test databases by running RAILS_ENV=test rails db:create && RAILS_ENV=test rails db:migrate in each directory of the projects
  • 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-get install rabbitmq-server
    • Enable the plugin rabbitmq_recent_history_exchange:
      • macOS: /usr/local/opt/rabbitmq/sbin/rabbitmq-plugins enable rabbitmq_recent_history_exchange
      • other systems: rabbitmq-plugins enable rabbitmq_recent_history_exchange
  • Install phantomjs. This is used for the frontend tests.

    • macOS: brew install phantomjs.
    • Arch Linux: sudo pacman -Sy phantomjs.
    • Ubuntu Linux: sudo apt-get install phantomjs.
  • 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:

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

Initialize backend repository

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

bundle config --local local.ontohub-models <absolute path to the ontohub-models repository>
bundle config --local local.gitlab_git <absolute path to the gitlab_git 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 install

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"\nPATH="$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 --pure-lockfile # install build dependencies
yarn run bower install # install runtime dependencies

To start the frontend, run yarn start.

Clone this wiki locally