Skip to content
Cindy Wu edited this page Jan 21, 2023 · 24 revisions

Welcome! We're excited that you are interested in checking out this project and maybe hacking on it. That's great! ✨

If you're looking to get set up, please follow these instructions for getting a local development environment up and running. By the end of this you should be able to run this app successfully. If not, please feel free to create an issue to bring our attention to anything missing.

Mac Setup

For this setup, please use the most recent version of OS X. If something doesn't work for you, or you'd just like to know more about a particular step, feel free to ask a developer (via slack).

  1. Install the command line tools

    xcode-select --install # and follow the prompts
  2. Install Homebrew.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Install git.

    brew install git
  4. Install chruby.

    brew install chruby
    echo 'source /usr/local/opt/chruby/share/chruby/chruby.sh' >> ~/.bash_profile
  5. Install ruby-build.

    brew install ruby-build
  6. Install ruby 3.0.0

    ruby-build 3.0.0 ~/.rubies/ruby-3.0.0
  7. Install rbenv

    brew install rbenv
    rbenv install 3.0.0
  8. Set ruby version to 3.0.0

    rbenv global 3.0.0
  9. Install Bundler. Do not use sudo here. If stuck, ask a developer in slack.

    gem install bundler
  10. Install Rails, if you don't have it already.

    gem install rails
  11. Install the Heroku Toolbelt

    brew tap heroku/brew && brew install heroku
  12. Install ImageMagick for image processing.

    brew install ImageMagick
  13. Reload your shell.

    source ~/.bash_profile
  14. Install node

    brew install node
Postgres Setup
  1. Install Postgres.

    brew install postgresql
  2. Start postgres on boot:

    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
  3. To start the server:

    pg_ctl -D /usr/local/var/postgres -l logfile start
  4. Initialize a postgres database

    initdb /usr/local/var/postgres -E utf8
  5. Create a postgres user.

    createuser --superuser jelly
  6. Create jelly development database:

    createdb -U jelly jelly_development
  7. Install the Postgres gem with architecture flags enabled.

    env ARCHFLAGS="-arch x86_64" gem install pg
  8. Install Puma gem w/ openssl options.

    brew install openssl
    brew link --force openssl
    gem install puma -- --with-cppflags=-I/usr/local/opt/openssl/include
  9. (optional) Install ElasticSearch.

If you're on a fresh install, install java with

brew cask install caskroom/versions/java8

And then put elasticsearch somewhere where you want it, e.g. home directory or your /usr/bin

curl -L -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.6.tar.gz
tar -xvf elasticsearch-2.4.6.tar.gz
Redis Setup
  1. Install redis

    brew install redis
  2. Start redis on boot:

    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

For environment variables, go ahead and add placeholders in your dotfiles.

Linux Setup

This setup was tested on Ubuntu 16.04. If something doesn't work for you, or you'd just like to know more about a particular step, feel free to ask a developer (via slack).

  1. Install Homebrew. If there are issues, you can find more detailed installation instructions here.

    mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  2. Install git.

    brew install git
  3. Install chruby.

    brew install chruby
    echo 'source /usr/local/opt/chruby/share/chruby/chruby.sh' >> ~/.bash_profile
  4. Install ruby-build.

    brew install ruby-build
  5. Install ruby 3.0.0

    ruby-build 3.0.0 ~/.rubies/ruby-3.0.0
  6. Install rbenv

    brew install rbenv
    rbenv install 3.0.0
  7. Set ruby version to 3.0.0

    rbenv global 3.0.0
  8. Install Bundler. Do not use sudo here. If stuck, ask a developer in slack.

    gem install bundler
  9. Install Rails, if you don't have it already.

    gem install rails
  10. Install the Heroku Toolbelt

    brew install heroku
  11. Install ImageMagick for image processing.

    brew install ImageMagick
  12. Reload your shell.

    source ~/.bash_profile
  13. Install node.

    brew install node
Postgres Setup

More detailed instructions for what is happening during these steps can be found here.

  1. Install Postgres.

    sudo apt update
    sudo apt install postgresql postgresql-contribbrew install postgresql
  2. Start postgres on boot:

    sudo -i -u postgres
  3. Create a superuser with the same name as your username (referred to as "user") by following the prompts on this command.

    sudo -u postgres createuser -s "user" -P
  4. Store your username password as an environment variable.

    echo 'export DB_PASSWORD="YOUR_PASSWORD"' >> ~/.bashrc
    echo 'export DB_USER="USER"' >> ~/.bashsrc
    source ~/.bashrc
    
  5. Initialize a postgres database.

    yarn install --check-files
    rails db:create
  6. Install the Postgres gem with architecture flags enabled.

    env ARCHFLAGS="-arch x86_64" gem install pg
  7. Install Puma gem w/ openssl options.

    brew install openssl
    brew link --force openssl
    gem install puma -- --with-cppflags=-I/usr/local/opt/openssl/include
Redis Setup

More detailed instructions here.

  1. Install redis.

    sudo apt update
    sudo apt install redis-server
  2. Open /etc/redis/redis.conf and replace supervised no with supervised systemd

Windows Setup

For this setup, please use Windows 10 Build 1909 and above. If something doesn't work for you, or you'd just like to know more about a particular step, feel free to ask a developer (via slack).

  1. Install Windows Subsystem for Linux (WSL). You may have to restart your computer after this.
Enable-WindowsOptionalFeature -Online -FeatureName  Microsoft-Windows-Subsystem-Linux
  1. Install Ubuntu through the Windows App store here. The rest of the installation will be run through the Ubuntu shell.

  2. Ensure Git is installed.

git --version
  
# if git isn't installed
sudo apt install git
  1. Install dependencies needed for Ruby.
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev

Additional info can be found here. 5. Install rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
  1. Install ruby-build.
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
  1. Install Ruby 3.0.0
rbenv install 3.0.0
rbenv global 3.0.0
ruby -v
  1. Install Bundler. Do not use sudo here. If stuck, ask a developer in slack.
gem install blunder
rbenv rehash
  1. Install node & yarn.
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
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 update
sudo apt-get install -y nodejs yarn
  1. Install rails.
gem install rails -v 6.0.2.2
rbenv rehash
rails -v
  1. Install heroku toolbelt.
gem install heroku
  1. Install ImageMagick.
sudo apt update
sudo apt install imagemagick
Postgres Setup
  1. Install Postgres for Windows here.
  2. Connect Postgres with WSL.
sudo apt update
sudo apt install libpq-dev
  1. To start the server:

    pg_ctl -D /usr/local/var/postgres -l logfile start
  2. Initialize a postgres database

    initdb /usr/local/var/postgres -E utf8
  3. Create a postgres user.

    createuser --superuser jelly
  4. Create jelly development database:

    createdb -U jelly jelly_development
  5. Install the Postgres gem with architecture flags enabled.

    env ARCHFLAGS="-arch x86_64" gem install pg
Redis Setup
  1. Install redis.

    sudo apt update

sudo apt install redis-server ``` 2. Update the redis config file.

sudo nano /etc/redis/redis.conf

Find supervised no line and change to supervised systemd since Ubuntu uses the systemd init system.

Jelly Poster Setup

  1. Add your SSH-Keys to Github if you haven't already.

  2. Clone the Jellyposter project.

    git clone [email protected]:jellypbc/poster.git
  3. Go to the jellyposter project directory.

    cd poster
  4. Install gems.

    bundle
  5. Reload your shell.

    source ~/.bash_profile
  6. Log into Heroku with the Heroku Toolbelt and add your public key

    heroku login
    heroku keys:add
  7. Add Heroku repositories remotes (so you can deploy).

    heroku git:remote -a jellyposter
  8. Prepare the test database.

    bundle exec rake db:test:prepare
  9. Install yarn.

    brew install yarn
  10. Install packages.

    yarn
  11. Get the environment variables.

  12. Boot up the server and be happy!

Starting the services

To start the rails server

bundle exec rails s

To start webpacker

bin/webpack-dev-server

To start sidekiq

bundle exec sidekiq

Docker

If you prefer to use Docker, you can set things up the first time using:

$ docker-compose build
$ docker-compose run app .docker/startup.sh

You can run the server and other services using the following command:

$ docker-compose up

This will start the rails server, sidekiq, webpacker, redis, postgres, grobid, and figures. If you just want to run the external services in docker, you can do so using:

$ docker-compose up grobid figures

To run an interactive rails console on the container:

docker exec -it $( docker ps | grep jelly | awk "{print \$1}" | head -n 1 ) bin/rails c