Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailer Settings and Documentation Updates #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions Doc/server_deploy,md

This file was deleted.

65 changes: 65 additions & 0 deletions Doc/server_deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Server development guide


## Get a Linux server

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

## Prepare the rails app

Clone the repository

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

Install ruby

Check this [instruction](https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-16-04) to install Ruby and rbenv, a Ruby version manager, into your machine.


Install ruby packages

gem install bundle
cd MYR_rails
bundle install


## Initialise the database and serve the website in development mode

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


## Update the database for competition

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

- Most front-end related files are under `MYR_rails/app/views`.
- Database file is under `MYR_rails/db`:

- Depending on the mode (development, test, production), you'll see a corresponding SQLite file. You will need to configure it manually.
- Edit the seed file under `seeds/` (e.g. `seeds/seeds2018.rb`) and run `bundle exec rake db:seed:seeds2018` to add your own admin users and missions to the competition.


## Run the server in production

### Reinitialise the database for production

cd tracking/MYR_rails
export RAILS_ENV=production
bundle exec rake db:migrate
bundle exec rake db:seed:seeds2018 # Replace where necessary

### Run the server in CLI or via Bash script

#!/bin/bash
cd tracking/MYR_rails

export RAILS_ENV=production
# Generate a SECRET_TOKEN; `rake secret` can generate one
export SECRET_TOKEN=<SECRET_TOKEN>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where SECRET_TOEKN is used?

# If you haven't already, make sure to generate a SECRET_KEY_BASE too
export SECRET_KEY_BASE=<SECRET_KEY_BASE>

bundle exec rails s -e production -b 0.0.0.0 -p 80 # Options are, well, optional

8 changes: 8 additions & 0 deletions MYR_rails/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@
config.action_mailer.default_url_options = { :host => "localhost:3000" }
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this. As in @kirs 's idea, the email will be previewed in a html page.

:address => "smtp.gmail.com",
:port => 587,
:authentication=> "plain",
:enable_starttls_auto=> true,
:user_name => ENV["GMAIL_USERNAME_DEV"],
:password => ENV["GMAIL_PASSWORD_DEV"],
}
end
10 changes: 5 additions & 5 deletions MYR_rails/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@
config.active_record.dump_schema_after_migration = false

# SMTP settings for gmail
config.action_mailer.default_url_options = { :host => "www.roboticsailing.org/2018/tracking" }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
config.action_mailer.default_url_options = { :host => "www.roboticsailing.org/2018/tracking" }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
user_name: "[email protected]",
password: "sailrobot",
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"],
authentication: "plain",
enable_starttls_auto: true
}
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ To run the server locally for development:
# gem is Ruby's package manager. You'll need to get that somehow.
gem install bundle
bundle install

# It looks like this should only be needed in production, but I always
# seem to need it. It should be a proper random token in production.
# To learn how to deploy to production, please read `Docs/server_deploy.md`.
export SECRET_KEY_BASE=blah

# Go!
bundle exec rails server -e development

# Run the database migrations, and launch the server!
bundle exec rake db:migrate RAILS_ENV=development
bundle exec rails server -e development # or bundle exec rails s -e development

Open http://localhost:3000/ in a browser to see it.

Expand Down