Skip to content

Get started with Vagrant

rrudling edited this page Sep 8, 2021 · 3 revisions

All code for the AIS and other applications that we have in THS Armada can be found here on our Github. When we develop the AIS, the main testing environment is on your own computer. To have a local version of the AIS you want to run it within a virtual machine. This document contains information on how to set up your local AIS.

Setup virtual environment and local AIS

Windows

  1. Download and install Vagrant and VirtualBox.
  2. Activate Vt-x in BIOS
  3. Go to Control panel > Program and functions > Activate/Deactivate Windows functions:
    • disable Hyper-V
    • enable Windows Hypervisor Platform
  4. Clone the AIS repo via SSH and cd into it (new to SSH? See how to generate a new SSH key and how to add it to your GitHub account)
    git clone git@github.com:armada-ths/ais.git
    cd ais
    
  5. Navigate to the directory which contains the provision.sh file: cd scripts/vagrant.
  6. Replace the content of provision.sh with the content of this file.
  7. Go back to the root directory: cd ../.. and then run vagrant up. This will create your virtual machine containing the AIS system. You can view your virtual machine in the Virtualbox GUI. Take a look at the Vagrantfile in the root and scripts/vagrant/provision.sh to see what goes on. You might have to run vagrant up as admin (and enable it to create new directories on your computer). Running vagrant up should create two directories under your user: .vagrant.d and .VirtualBox.
  8. Enter your VirtualBox with vagrant ssh.
  9. Now you are inside the virtual environment. Run sed -i 's/\r//' *.sh. This will stop windows from converting line endings to CRLF. Also, run git config --global core.autocrlf true. Default setting is that file endings will be converted to Windows CRLF and then it will appear as you have done A LOT of changes to your working directory compared to the master branch.

To make sure that git will always convert your CRLF line endings to LF when committing (and the other way around when in the opposite direction) it is recommended to have this setting if you are on a Windows computer. You can read here and here. 9. Start the server with ./dev-runserver.sh. Browse to localhost:8080 to see your local version of the AIS!

Ubuntu

  1. Download and install:
    • Vagrant
    curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
    sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
    sudo apt-get update && sudo apt-get install vagrant
    • VirtualBox
    wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
    wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
    sudo apt-get update && sudo apt-get install virtualbox-6.1
  2. Clone the AIS repo via SSH and cd into it (new to SSH? See how to generate a new SSH key and how to add it to your GitHub account)
    git clone git@github.com:armada-ths/ais.git
    cd ais
  3. Run vagrant up. This will create your virtual machine containing the AIS system. You can view your virtual machine in the Virtualbox GUI. Take a look at the Vagrantfile in the root and scripts/vagrant/provision.sh to see what goes on. You might have to run vagrant up as admin (and enable it to create new directories on your computer). Running vagrant up should create two directories under your user: .vagrant.d and .VirtualBox.
  4. Enter your VirtualBox with vagrant ssh.
  5. Now you are inside the virtual environment and you can start the server with ./dev-runserver.sh. Browse to localhost:8080 to see your local version of the AIS!

Mac

  1. Download and install Vagrant and VirtualBox.
  2. Clone the AIS repo via SSH and cd into it (new to SSH? See how to generate a new SSH key and how to add it to your GitHub account)
    git clone git@github.com:armada-ths/ais.git
    cd ais
  3. Run vagrant up. This will create your virtual machine containing the AIS system. You can view your virtual machine in the Virtualbox GUI. Take a look at the Vagrantfile in the root and scripts/vagrant/provision.sh to see what goes on. You might have to run vagrant up as admin (and enable it to create new directories on your computer). Running vagrant up should create two directories under your user: .vagrant.d and .VirtualBox.
  4. Enter your VirtualBox with vagrant ssh.
  5. Start the server with ./dev-runserver.sh. Browse to localhost:8080 to see your local version of the AIS!

Import the developer database

When setting up your local machine a database user and database will be created with the name ais_dev. We want to replace this one with a bigger database that is a copy of the real one to make sure our developing environment is as real as possible. Download and store the ais-developer-database.sql file in your AIS directory root (ask the current Head of Internal Systems from where you can download this file).

This database is different from the "real" one in the following ways:

  • It has the accounts listed in this document to be used for testing.
  • It does not have all applications for each recruitment period.
  • It has some default phone numbers and email addresses for the banquet- and university relations participants.

After vagrant up and vagrant ssh: Log into psql as postgres user: psql -U postgres Drop the old database: drop database ais_dev; Quit psql: \q Now create the database as user postgres: psql -U postgres < ais-developer-database.sql

Clone this wiki locally