Skip to content

Latest commit

 

History

History
107 lines (66 loc) · 3.91 KB

README.markdown

File metadata and controls

107 lines (66 loc) · 3.91 KB

Votta on Rails

Build Status Security Dependency Status Code Climate Test Coverage Dependency Status

Join the chat at https://gitter.im/franklinyu/Votta

deploy on server

Prerequisite:

  • Ruby (version shown in the file .ruby-version)
  • PostgreSQL

First, make sure that you have Bundler installed:

$ gem install bundler

Then install the bundle with Bundler

$ bundle install --deployment --without development test doc

Set up the environment variables DATABASE_URL, RAILS_ENV, and SECRET_KEY_BASE. Typically RAILS_ENV should be production; DATABASE_URL should be a connection string; SECRET_KEY_BASE should be bytes (over 30 bytes, typically 128 bytes) in hexadecimal form, which can be generated by

$ bundle exec rails secret

Now migrate the database:

$ bundle exec rails db:migrate

Now you can launch Votta with Puma:

$ bundle exec puma -C config/puma.rb

Note that the -C flag is aliased to --config. You can change the port (default to 3000) with environment variable PORT.

note for Heroku

Heroku Ruby buildpack doesn't recognize .ruby-version file. To deploy on Heroku, manually spedify it in Gemfile.

deploy with Docker

The easiest way to use Docker is Docker Compose. Docker 1.12.0 or above, and Docker-Compose 1.6.0 or above, are required. Concerning the environment variables, only SECRET_KEY_BASE is required when deploying with Docker; PORT is respected if found. They can be specified as environment variables, like

$ SECRET_KEY_BASE=deadbeef PORT=8080 docker-compose up

or specified in environment file

$ cat .env
SECRET_KEY_BASE=deadbeef
PORT=8080
$ docker-compose up

In this case, the secret key base can be generated by

$ docker-compose run web rails secret

so that we don't need Ruby outside the container.

Instead of downloading (or cloning) the entire repository, one can also download the docker-compose.yaml only, and replace the build: . with image: franklinyu/votta-web, thanks to Docker Hub. The images are built by continuous integration, so images there would at least pass all the tests.

test

Prerequisite:

  • Ruby (version shown in the file .ruby-version)

First, make sure that you have Bundler installed:

$ gem install bundler

Then install the bundle with Bundler:

$ bundle install --without development production doc

You need to re-run with the --deployment flag if this fails (which means you are testing on an online container). Now test with RSpec:

$ bundle exec rspec