Getting started with Monorail development on Linux

These steps should only need to be taken once when setting up a new development machine:

  1. Install basic build dependencies:

    1. sudo apt-get install git build-essential automake
    2. Install Chrome depot_tools and ensure it is in your $PATH.
  2. Check out the Monorail source code repository:

    1. mkdir ~/src/
    2. cd ~/src/
    3. fetch infra (Googlers may alternatively fetch infra_internal, but note that gclient sync will then always sync based on the current infra_internal branch instead of the current infra branch.)
    4. cd infra/appengine/monorail
  3. Install and configure the gcloud CLI:

    1. It should be fetched for you by fetch infra above under ~/src/infra/cipd/gcloud/bin. Add it to your PATH in .bashrc.
    2. Otherwise, follow https://cloud.google.com/sdk/docs/install (Googlers on Linux may use sudo apt-get install -y google-cloud-sdk)
  4. Configure gcloud:

    1. gcloud auth login
    2. gcloud config set project monorail-dev
  5. Install and configure Docker:

    1. sudo apt install docker-ce (Googlers will need to follow instructions at go/docker)
    2. sudo systemctl start docker
    3. sudo adduser $USER docker
    4. Logout and back in to pick up the group change.
    5. docker run hello-world to verify installation.
    6. gcloud auth configure-docker
  6. Configure the MySQL database:

    1. sudo apt install libmariadb-dev
    2. `docker-compose -f dev-services.yml up -d mysql
    3. docker cp schema/. mysql:/schema
    4. `docker exec -it mysql -- mysql --user=root -e 'CREATE DATABASE monorail;'
    5. docker exec -it mysql -- mysql --user=root monorail < schema/framework.sql
    6. docker exec -it mysql -- mysql --user=root monorail < schema/project.sql
    7. docker exec -it mysql -- mysql --user=root monorail < schema/tracker.sql
    8. docker exec -it mysql -- mysql --user=root monorail -e "UPDATE User SET is_site_admin = TRUE WHERE email LIKE '%@example.com';"
  7. Install Monorail frontend (node) prerequisites:

    1. curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
    2. source "$HOME/.nvm/nvm.sh"
    3. nvm install 12.13.1

These steps will need to be repeated regularly when developing Monorail:

  1. Enter the virtual environment (in every new terminal you create):

    1. eval $(../../go/env.py)
    2. source ./venv/bin/activate
  2. Install per-language dependencies (every few days to ensure you're up to date):

    1. make jsdeps
  3. Launch the Monorail server (once per machine/per reboot):

    1. make serve
    2. Browse the app at localhost:8080 your browser.
  4. Login with test user (once per machine or when starting with a fresh database): 1. Sign in using test@example.com 1. Log back out and log in again as example@example.com 1. Log out and finally log in again as test@example.com.