Skip to content
Robert Syme edited this page Aug 25, 2016 · 62 revisions

Setup (using docker - experimental)

Install docker. Then:

$ cd afra
$ cp example.env.yml env.yml
# edit env.yml -- add fb app id and secret
$ docker build -t afra .
$ docker run -t -i -p 9292:9292 afra

The current docker setup is not meant for production deployment. It's for demo, test, and development only.


Setup (without docker)

Ruby 2.1.x

ruby-install & chruby is prescribed so as to facilitate troubleshooting potential issue with Ruby setup. You can use rbenv, etc. as well.

Ruby 2.x ships with RubyGems 2.x and Rake 10.x which are required to setup and run Afra. If you install Ruby from your package manager, you may have to install RubyGems and Rake separately.

# install ruby-install (https://github.com/postmodern/ruby-install).
$ cd
$ wget -O ruby-install-0.5.0.tar.gz https://github.com/postmodern/ruby-install/archive/v0.5.0.tar.gz
$ tar xvf ruby-install-0.5.0.tar.gz
$ cd ruby-install-0.5.0/
$ sudo make install

# install latest stable ruby
$ sudo ruby-install ruby

# install chruby (https://github.com/postmodern/chruby)
$ cd
$ wget -O chruby-0.3.8.tar.gz https://github.com/postmodern/chruby/archive/v0.3.8.tar.gz
$ tar xvf chruby-0.3.8.tar.gz
$ cd chruby-0.3.8/
$ sudo make install

Perl 5

Should be pre-installed on your system.

NodeJS

NodeJS and node package manager, npm, are required to setup and run Afra. It's recommended to install them via your package manager. Some package manager will automatically install npm if you install node. Some may not.

# On Mac.
$ brew install node

# On Debian & Ubuntu
$ apt-get install nodejs nodejs-legacy npm

My NodeJS and npm versions: 0.10.26 & 1.4.3.

Postgres 9.3

It's recommended to install Postgres via your package manager.

# On Mac.
$ brew install postgresql libpqxx

# On Debian / Ubuntu
$ sudo aptitude install postgresql-9.3 postgresql-contrib-9.3 libpq-dev

Configuring

See if you can connect to Postgres.

$ createdb testdb && dropdb testdb

If the above command fails with error like "Couldn't connect to Postgres", you will have to change pg_hba.conf.

$ sed -i bak 's|\(.*128.*\)md5|\1trust|' <location/of/pg_hba.conf>

If the above command fails with error like "Couldn't find role '...'", you will have to create a "role" for yourself.

$ sudo -u postgres createuser --interactive # when asked, make role superuser

Afra

$ git clone https://github.com/yeban/afra.git
$ cd afra

# install dependencies and configure Afra
$ rake

# import test data
$ rake import\[data/annotations/Solenopsis_invicta/Si_gnF.gff\]

# launch Afra server
$ rake serve

Open http://localhost:9292 in your browser and start curating!

Production

Using reverse proxy setup on http://afra.sbcs.qmul.ac.uk with Nginx as the frontend server.

# nginx.conf
# [...]
http {
    sendfile on;

    server {
        listen       80;
        server_name  localhost;

        location @afra {
                proxy_redirect off;
                proxy_read_timeout 180;
                proxy_intercept_errors on;
                proxy_set_header   X-Forwarded-Host $host;
                proxy_set_header   X-Sendfile-Type     X-Accel-Redirect;
                proxy_set_header   X-Accel-Mapping     /Users/priyam/src/afra/data/jbrowse/=/files/jbrowse/;
                proxy_pass http://localhost:9292;
        }

        location /files/jbrowse/ {
          internal;
          alias /Users/priyam/src/afra/data/jbrowse/;
        }

        location / {
            root   /Users/priyam/src/afra/www;
            index  index.html;
            try_files $uri $uri/ @afra;
        }
    }
}
# afra.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>uk.ac.qmul.sbcs.afra</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/bin/chruby-exec</string>
                <string>2.1.0</string>
                <string>--</string>
                <string>bundle</string>
                <string>exec</string>
                <string>rake</string>
                <string>serve</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>priyam</string>
        <key>WorkingDirectory</key>
        <string>/Users/priyam/src/afra</string>
</dict>
</plist>