Skip to content

Creating the CIViC AMI

Alex Handler Wagner, PhD edited this page Sep 28, 2016 · 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-20be7540. This image was selected from Canonical's AMI locator tool for the following characteristics:

Attribute Value
Zone us-west-2
Version 14.04 LTS
Architecture amd64
Instance type hvm:ebs
Release August, 2016

##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 libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev emacs24

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.1 rbenv global 2.3.1

7. Install bundler

gem install bundler rbenv rehash

8. Install Node

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install nodejs

9. Install rails

gem install rails -v 4.2.6 rbenv rehash

10. Install and configure postgresql

sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list" wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get install postgresql-common sudo apt-get install postgresql-9.5 libpq-dev

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/9.5/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

3. Update the CIViC server database

rake db:create db:migrate

psql -d civic_development -f ~/civic-server/db/localdb.sql


##Install and configure the CIViC client
1. Install the CIViC client

cd git clone https://github.com/genome/civic-client.git cd civic-client sudo npm install -g bower gulp sudo npm install sudo bower install --allow-root sudo chown ubuntu -R ~/.config/

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](https://goo.gl/aFmw6D) 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!
Clone this wiki locally