Skip to content

Latest commit

 

History

History
340 lines (224 loc) · 9.38 KB

INSTALLATION.md

File metadata and controls

340 lines (224 loc) · 9.38 KB

Installation

The app uses Ruby 2.3.4 and Rails 5.0.5. Please stick to these versions.

The steps below should be straightforward for Linux and macOS users. Windows users please refer to this guide for tips on setup.

Commons errors faced during installation are documented in this guide.

1) Install Postgres (click to expand)

Postgres

After installing Postgres, if you are asked to create a new user, please follow these instructions.

A. macOS

Install via Homebrew

brew install postgresql

then start the postgres server:

postgres -D /usr/local/var/postgres

For more information, follow this postgresql guide for a more detailed setup

B. Linux

Install using your package management software (e.g. apt, yum, etc.).

It may also be necessary to install a separate development files package or the Ruby gem may not compile. On Ubuntu/Debian, this package is called postgresql-server-dev-X.Y (e.g. postgresql-server-dev-9.4). If you are unsure of what the package is for your distribution, continue following the instructions; usually bundler will let you know what you need to install.

Most likely, PostgreSQL will be running under a new user called "postgresql" and your user will not have permission to connect to the database. You can add yourself as a user by running:

sudo -u postgres createuser -s $(whoami)
createdb $(whoami)

C. Windows

Install via graphical installer

Install Gems

After cloning the app on your local machine, in your terminal run the following command in the /ifme directory

bundle install
2) Install Ruby on Rails (click to expand)

Ruby on Rails

If you do not have Rails, use this handy guide.

If you're updating an existing installation through RVM or rbenv, continue to (A) or (B).

Option (A) RVM

Assuming you have RVM installed, update to the latest version

rvm get stable --autolibs=enable

Close and re-open the terminal window

rvm install ruby-2.3.4

Check that Ruby has been updated by running ruby -v.

Option (B) rbenv

Follow instructions for updating rbenv at the project's GitHub. Make sure you also upgrade ruby-build if you used Homebrew to install rbenv.

Run the following to install Ruby 2.3.4:

rbenv install 2.3.4

Gems: After updating or installing Ruby

Update the gem manager by running gem update --system.

Update your gems by running gem update.

If you are missing bundler, please install it

gem install bundler

Make a gemset for the specific Ruby on Rails version through RVM or rbenv. Continue to (A) or (B).

Option (A) RVM

rvm use ruby-2.3.4@rails5.0.5 --create

Option (B) rbenv

rbenv-gemset

3) Install Yarn (click to expand)

Install Yarn

There are step-by-steps here for all of the major operating systems.

cd client/
yarn install

Configuration Files

Mandatory (click to expand)

Mandatory

There are two config files: config/env/test.env and config/env/development.env. To run the app locally, you should modify test.env and development.env. They are ignored in git to prevent accidentally committing sensitive information.

Automatic setup

For your development and test environments, you can automatically generate the env files by running bin/rake setup_workspace.

Manual setup

Copy the sample files to create your own configuration files:

cp config/env/test.example.env config/env/test.env cp config/env/development.example.env config/env/development.env

Run rake secret twice to generate values for SECRET_KEY_BASE and DEVISE_SECRET_KEY. The values in test.env and development.env can be the same.

BE CAREFUL: The secret should be in the test.env and development.env NOT the config/env/test.example.env or config/env/development.example.env files. The example files are not ignored by git.

Optional (click to expand)

Optional

The following are not mandatory, but are required if you would like to test/use these features.

Pusher

Pusher is used in-app notifications. If you would like to use this feature in your local environment, please create your own account, generate keys, and update PUSHER_APP_ID, PUSHER_KEY, PUSHER_SECRET in config/env/test.env and config/env/development.env.

Google OAuth 2.0 IDs

Google OAuth 2.0 IDs is used for OAuth (Sign in with Google) and Calendars (refill dates for Medications). If you would like to use this feature in your local environment, please create your own account, generate keys, and update GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in config/env/test.env and config/env/development.env. You'll need to activate both the Google+ API and the Contacts API for OAuth, and the Calendar API for Calendars. Under the credentials tab, make sure to add the Authorized redirect URI as http://localhost:3000/users/auth/google_oauth2/callback. Note, you may have to hit the Save button twice for this to take effect.

We have a wiki with step by step instructions if you get lost in the process.

Google API

Google API is used for location autocomplete, specifically the Maps JavaScript API (which needs to be activated). If you would like to use this feature in your local environment, please create] your own account, generate keys, and update GOOGLE_API_KEY in config/env/test.env and config/env/development.env.

We have a wiki with step by step instructions if you get lost in the process.

Cloudinary

Cloudinary is used to store profile pictures. If you would like to use this feature in your local environment, please create your own ]account, generate keys, and update CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, and CLOUDINARY_API_SECRET in config/env/test.env and config/env/development.env.

If want to generate static images through the Cloudinary CDN, run heroku run rake cloudinary:sync_static.

Email Notifications

To get email notifications working, you must configure SMTP settings in config/env/test.env and config/env/development.env.

The following guide from Launch School is helpful.

Please do not test these with the Testing Accounts. Create new accounts with valid email addresses!

If you want to test out scheduled emails, run the following commands:

bundle exec rake scheduler:send_take_medication_reminders

bundle exec rake scheduler:send_refill_reminders

bundle exec rake scheduler:send_perform_strategy_reminders

bundle exec rake scheduler:send_meeting_reminders

Letter Opener

The gem letter_opener enables test e-mails to be sent without actually sending an e-mail accidentally to someone through SMTP.

You can disable this gem when you deploy the app by commenting it out.

# gem "letter_opener", :group => :development

You can read more about this gem here.

Secret Share

Secret Share is a feature to share a moment, with a secret URL for a certain amount of time.

You can enable this feature by adding config.secret_share_enabled = true to the development.rb file.

Running the App Locally

Create the development and test databases:

bin/rake db:setup db:test:prepare

Run rake slugs:slugify to update existing entries in the database with slugs (e.g. moments/fun-slug)

Start the local server:

bin/start_app

To view the app, go to http://localhost:3000.

To view the app on your mobile device, go to http://[YOUR IP ADDRESS]:3000.

Docker (click to expand)

Docker

Assuming Docker is setup, you can start the server using

docker-compose up

or open a shell using

docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm app
bash
Vagrant (click to expand)

Vagrant

Assuming Vagrant is setup, you can add the following line to your Vagrantfile. Make sure to add it exactly as below - with : and not quotes, or it may not work properly.

config.vm.network :forwarded_port, guest: 3000, host: 3000

Rails binds to 127.0.0.1, so you may need to specify 0.0.0.0 when starting the server for localhost.

bin/rails server -b 0.0.0.0

Accessing the Database

rails db

Note that ifme_test is used when running unit tests.