Skip to content

1.Server deployment guide

Tony Yu Cao edited this page Jul 27, 2019 · 7 revisions

Server development guide

Get a linux server

You can use your own server or get a cheap VPS from Digital Ocean started $5 per month. (referral code to be inserted here)

Prepare rails app

Clone the repository

git clone https://github.com/WRSC/tracking.git

Install ruby

Check this instruction

Install ruby packages

gem install bundler -v 1.16.4
cd MYR_rails
bundle install

Initialise the database and serve the website in development mode

export RAIL_ENV=development
bundle exec rake db:migrate
bundle exec rails s 

Now you should able to view the website at http://localhost:3000

Update the database for a competition

To update the website for a new competition, both visual front-end and database back-end need to be changed.

  • Most front-end related files are under /MYR_rails/app/views folder.

  • Database file is under /MYR_rails/db folder.

    • Depends on the mode, you'll see one (development, production, test) of SQLite database there. You do need to configure them manually
    • Edit the seed file under seeds folder, the seeds2018 is self-explanatory. After that run bundle exec rake db:seed:seeds2018 to add admin users and missions to the competition.

Run the server in production environment

Repeat the initialise the database and update the database step in production mode

cd MYR_rails # Assume you are under /tracking/MYR_rails folder
export RAIL_ENV=production
bundle exec rake db:migrate
bundle exec rake db:seed:seeds2018 # Replace when necessary

Run in CLI or create a bash script

#!/bin/bash
export RAIL_ENV=production
export SECRET_KEY_BASE=... # Fill in a SECRET_KEY key, 'rake secret' can generate one

cd tracking/MYR_rails
bundle exec rails s -e production -b 0.0.0.0 -p 80

Now the website should be running at http://<yourIP/domain>