Skip to content

Creating the CIViC AMI

Alex H. Wagner, PhD edited this page Sep 26, 2018 · 12 revisions

This is a step-by-step guide to configuring a CIViC development EC2 instance on Amazon Web Services (AWS). While we currently provide an AMI for the purpose of developing CIViC, this page provides developers with detailed knowledge of how that AMI was configured. This guide assumes familiarity with the AWS EC2 console. For more information about the console and setting up an account, please see the getting started guide.

Initial AMI selection

We selected the Canonical Ubuntu image ami-0bbe6b35405ecebdb. This image was selected from Canonical's AMI locator tool for the following characteristics:

Attribute Value
Zone us-west-2
Version 18.04 LTS
Instance type hvm:ebs

Configuring an initial EC2 instance

The following steps follow the steps of the Amazon instance creation wizard in the EC2 management console. The image in step 1 is only available in us-west-2 (Oregon), please ensure that your console is searching the correct region (top toolbar, right).

  1. Select an AMI: Select the AMIs submenu on the EC2 console (left toolbar, under Images). Search Public images for AMI ID : ami-20be7540. Right click on the result from this search and select Launch.

  2. Choose an instance type: Choose the t2.medium instance type. Note: this instance type is only needed for installing and configuring the AMI. Once the AMI has been created, subsequent instances used for CIViC development may be of type t2.micro.

  3. Configure Instance Details: The default values on this page may be used. Protect against accidental termination is a recommended, but not necessary, option to select.

  4. Add Storage: Only a root volume is necessary. The default values of 8GiB and Magnetic are recommended.

  5. Tag Instance: Add labels to your instance. See the Amazon documentation for more information about tagging EC2 resources.

  6. Configure Security Group: Create or select a security group with the following inbound rules:

    Type Protocol Port Range Source
    SSH TCP 22 0.0.0.0/0
    Custom TCP Rule TCP 3000-3001 0.0.0.0/0
  7. Select a key pair for access: Select an existing key pair or create a new one. See the Amazon documentation for more information on this subject.

Update instance and install and configure dependencies

  1. After configuring and initializing the instance, log into the running instance.

  2. Update the pre-installed system packages

    sudo apt-get update
    sudo apt-get upgrade
    
  3. Install Canonical repository dependencies

    sudo apt-get install curl git zlib1g-dev build-essential libssl1.0-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev libpq-dev python
    
  4. Configure git

    git config --global core.editor vim
    
  5. Install rbenv

    cd
    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
    exec $SHELL
    
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
    echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
    exec $SHELL
    
  6. Install ruby

    rbenv install 2.3.7
    rbenv global 2.3.7
    
  7. Install bundler

    gem install bundler
    rbenv rehash
    
  8. Install Yarn

    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    sudo apt-get update && sudo apt-get install yarn
    
    echo 'export PATH="/home/ubuntu/.yarn/bin:$PATH"' >> ~/.bashrc
    exec $SHELL
    
  9. Install rails

    gem install rails -v 4.2.10
    rbenv rehash
    
  10. Install and configure postgresql

    sudo apt-get install postgresql-common postgresql
    
    sudo -u postgres createuser ubuntu -s
    sudo -u postgres psql
      > \password ubuntu
      > Enter new password: dev
      > Enter it again: dev
      > \q
    sudo service postgresql restart
    

Install and configure the CIViC server

  1. Install the CIViC server

    git clone https://github.com/genome/civic-server.git
    
    cd civic-server
    bundle install
    rbenv rehash
    
  2. Configure rails to work with postgresql

    sudo vi /etc/postgresql/10/main/pg_hba.conf
    
     # Database administrative login by Unix domain socket
     local   all             all                                     trust
    
     # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
     # "local" is for Unix domain socket connections only
     local   all             all                                     trust
     # IPv4 local connections:
     host    all             all             127.0.0.1/32            trust
     # IPv6 local connections:
     host    all             all             ::1/128                 trust
    
    sudo service postgresql restart
    
  3. Update the CIViC server database

    rake db:create db:migrate
    
    rake civic:load[force]
    

Install and configure the CIViC client

  1. Install the CIViC client

    cd
    git clone https://github.com/genome/civic-client.git
    cd civic-client
    yarn install
    yarn global add bower
    bower install
    yarn global add gulp
    
  2. Configure the CIViC client

    git update-index --assume-unchanged gulp/server.js
    
    vi gulp/server.js
    

    Change the host entry in the config from 127.0.0.1 to 0.0.0.0

Create AMI

  1. (Optional) Shut down the civic developer instance: On the EC2 control panel Instances subpanel, right-click on the running civic developer instance, and select Instance State -> Stop.
  2. Create image from the civic developer instance: Right-click on the civic developer instance, and select Image -> Create Image. On the pop-up dialogue, add an image name and description, and then click Create Image.
  3. Rename snapshot: On creating an image, a new snapshot will be created. Find this in the Snapshots subpanel of the EC2 dashboard. Select the new image, hover over the name field, and select the pencil_edit icon that appears. Enter a new name that matches your image name from step 2.
  4. (Optional) Make your AMI public: In order to find your AMI from another AWS account, you will need to make the AMI public. In the AMIs subpanel of the EC2 dashboard, right-click on the newly created AMI and select Modify Image Permissions. Select the Public radio button, and press Save.

Next steps

You now have recreated a copy of the CIViC developer AMI. From here, launch instances to start developing on CIViC!