Skip to content

IBM-DSE/CognitiveBank

Repository files navigation

Cognitive Bank

Build Status

Installation

Manual

The essential pieces that you need are to install ruby, then bundler, then rails.

  • Install Ruby 2.4.0 with one of the following:

    Or visit the official Installing Ruby documentation for an alternative

  • Install Bundler as a "gem" (Ruby's package manager, like NPM)

    gem install bundler
  • Clone this repository and change directory to project root

    git clone https://github.ibm.com/ATAT/CognitiveBank.git && cd CognitiveBank
  • Install packages with bundler

    bundle install
  • Set up the database

    rails db:setup
  • Run the server in development mode

    rails server
  • Visit http://localhost:3000 from a browser

Docker

copy .env.example to .env in your working directory and fill it in with your Bluemix service values

Quick Deploy in Development Mode

With docker from GitHub:

docker build -t cognitivebank_dev https://github.ibm.com/ATAT/CognitiveBank.git
docker run -it -p 3000:3000 --env-file .env cognitivebank_dev

With docker from local code:

docker build -t cognitivebank_dev .
docker run -it -p 3000:3000 --env-file .env cognitivebank_dev

With docker-compose from local code:

docker-compose build
docker-compose up

Visit http://localhost:3000 from a browser

Local Development with Live Reload

git clone https://github.ibm.com/ATAT/CognitiveBank.git && cd CognitiveBank
docker build -t cognitivebank_dev .
docker run -it -p 3000:3000 --env-file ../.env -v `pwd`:`pwd` -w `pwd` cognitivebank_dev rails db:migrate && rails server

Visit http://localhost:3000 from a browser
Modify any files in /app and refresh browser to view updates

Production

(These instructions are for Ubuntu, other OSes may be different)

  • Get a domain name and point it to your server
  • Open ports 80 and 443
  • Install NGINX on your server
  • Copy production/CognitiveBank-nginx to /etc/nginx/sites-available/CognitiveBank on your server
  • Modify the file on your server (/etc/nginx/sites-available/CognitiveBank) with the domain name pointing to your server:
    server_name <DOMAIN_NAME>;
    
  • Enable the new site configuration
    cd /etc/nginx/sites-enabled
    rm default
    ln -s /etc/nginx/sites-available/CognitiveBank CognitiveBank
  • Run certbot on your server to get an SSL certificate
  • Build and run the docker container
    docker build -t cognitivebank_prod --build-arg RAILS_ENV=production https://github.ibm.com/ATAT/CognitiveBank.git
    docker run -d -p 3000:3000 --env-file .env -v CognitiveBank:/CognitiveBank/public cognitivebank_prod
  • Visit your domain name from a browser