Skip to content

Ruby project: Finance platform online to learn trading & share intelligence.

Notifications You must be signed in to change notification settings

RomainClaret/bsc.web.project2

 
 

Repository files navigation

Cloud Finance

Build Status

Ruby Project by Romain Claret, Matthieu Bandelier, & Fabio Marques

What's not here must be on the wiki ;)

Useful links

Used particular gems

Global

Development

  • 'byebug' # debugger and ctrl-d to release

Staging

  • 'puma'
  • 'bcrypt', '~> 3.1.7'

Production

  • 'rails_12factor'

Usage

Development on local container

Reminder

Do once:

Do the installation setup of the container with instructions ( repository & Containers) here: https://github.com/HE-Arc/demo-rails-application

$ cd container_install_directory
$ git clone https://github.com/HE-Arc/Finance_Cloud.git

Do each time:

$ cd container_install_directory
$ docker-compose up -d    # starts the VMs
$ docker exec -it ror_web_1 /bin/bash   # go to the web VM
# su username
$ cd /usr/src/app/Finance_Cloud
$ bundle install --without production # to do after gemfile modifications
$ rails s -b 0.0.0.0  # run the server locally

Do for "security" updates:

Create security update:

# su username
$ cd /usr/src/app/Finance_Cloud
$ git checkout -b rails-upgrade # create rails-upgrade branch
$ sed -i "s/gem 'rails', '4.2.5'/gem 'rails', '4.2.5.1'/" Gemfile # rename rails version
$ bundle update rails
$ bundle exec rake
$ git add -p . # -p is used to choose for to commit (y=yes, n=no, a=always) could use -A instead as well for adding all modifications
$ git commit -m "Security update for rails"

Deploy security update on the staging server:

$ git checkout master
$ git merge rails-upgrade
$ cap deploy

Production on heroku Finance Cloud:

Do each time:

From the local container as username

$ cd /usr/src/app/Finance_Cloud
$ git push heroku master
$ heroku run rake db:migrate # migrate if needed
$ heroku run rake db:seed # seed database if needed

Staging on school's nginx server Finance Cloud:

Do once:

From the local container as root

# usermod -l username ruby    # remplace username by your server username [romain, matthieu, fabio]
# vi /etc/sudoers.d/ruby    # remplace ruby by username
# su username

From the local container as username

$ ssh-keygen # no passphrase
$ more ~/.ssh/id_rsa.pub  # copy the public key

From the remote server (ssh)

$ vi ./ssh/authorized_keys  # add the copied public key from local container
$ ssh-keygen # no passphrase
$ more ~/.ssh/id_rsa.pub  # copy the public key

From your browser:

Go to https://github.com/settings/ssh and add the copied remote server public key

From the local container as username

$ cd /usr/src/app/Finance_Cloud
$ sudo bundle install
$ bundle exec cap install
$ bundle exec cap staging deploy

From the remote server (ssh)

$ sudo vi /etc/service/puma/run
cd "/var/www/Finance_Cloud/current"
$PUMA_ENV="/var/www/config/puma.rb"

$ vi ~/www/config/nginx.conf
Environment “staging”
root /var/www/Finance_Cloud/current/public
PUMA_ENV="/var/www/config/puma.rb"
directory “/var/www/app/current”

Do each time:

From the local container as username (NB push changes to git repo)

$ bundle exec cap staging deploy

Tests

Example with User model

Generate test files (first time only)

$ rails generate scaffold user username:string email:string password_digest:string --skip

Unit Tests

Preparing application for testing

$ rake db:migrate
$ rake db:test:load

Running unit tests

$ ruby -Itest test/models/user_test.rb

General

Run all tests

$ rake test

About

Ruby project: Finance platform online to learn trading & share intelligence.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 45.3%
  • CSS 28.1%
  • HTML 24.9%
  • JavaScript 1.3%
  • CoffeeScript 0.4%