-
Deployed application URL - https://jimmy-buddy-finder-f97708d96ef8.herokuapp.com/
-
Code Climate URL - https://codeclimate.com/github/tamu-edu-students/jimmy-gym-buddy-finder
Note: For CSCE-606 Project Verification, to skip Google Developer's Console setup for Omniauth and Amazon AWS S3 Bucket setup, please contact the team members and get the {master.key} beforehand.
To get started with the project, follow these steps:
-
Clone the Repository
git clone <repository-url> cd <project-directory>
-
Install Dependencies. Ensure you have Ruby and Bundler installed.
gem install bundler bundle install
-
Setup Database. Set up the database by running:
rails db:migrate
-
Omniauth Authentication Setup
The app uses Omniauth for Google authentication. To configure Google OAuth:
- Follow the Google OAuth setup documentation.
- Make sure to create a Google Developer Console project, set up OAuth credentials, and configure the redirect URI to match your Heroku app's domain.
- The required gems and corresponding configuration has been done already and can be found in
config/initializers/omniauth.rb
. - The following environment variables are to setup in Rails credentials in order for omniauth to work:
google: client_id: <google-client-id> client_secret: <google-client-secret>
-
Setup Secrets
-
To add environment variables securely in Rails credentials, use the following command:
EDITOR="vim" rails credentials:edit
-
This command does the following:
- Opens the encrypted
config/credentials.yml.enc
file for editing. - Allows you to add environment variables (e.g., API keys, secrets).
- Opens the encrypted
-
Once saved, Rails encrypts the file using the
config/master.key
. Thismaster.key
is essential to decrypt the credentials file at runtime. Theconfig/master.key
is automatically generated when you runrails credentials:edit
for the first time.
-
-
Verify Setup. Start the Rails server:
rails server
Visit http://localhost:3000
in your browser to confirm the app is running.
The project includes two types of test suites: RSpec and Cucumber. Follow the steps below to run the tests.
RSpec is used for unit and integration testing. To run the RSpec tests:
bundle exec rspec
Cucumber is used for behavior-driven development (BDD) and testing user scenarios. To run the Cucumber tests:
bundle exec cucumber
This guide will walk you through the process of deploying the Jimmy - Gym Buddy Finder Ruby on Rails app on the Heroku platform. It includes steps for setting up database, real-time chat, and image storage.
Before starting the deployment process, ensure you have the following:
-
A Heroku account and Heroku CLI installed
-
AWS account for S3 setup
-
Local Rails development environment set up
To store profile images, you'll need to create an Amazon S3 bucket.
- Follow the instructions to Create an S3 Bucket. 2. Once the bucket is created, obtain the following credentials from AWS:
- Access Key ID
- Secret Access Key
- The following environment variables are to setup in rails credentials in order for aws s3 bucket connection to happen:
aws: access_key_id: <aws-access-id> secret_access_key: <aws-secret-key>
- Follow the steps in Setup Secrets section to setup rails credentials for AWS secrets.
-
Log in to your Heroku account using the CLI:
heroku login
-
Create a new Heroku app:
heroku create <app-name>
- This will create a new Heroku app on your Heroku account.
- It also generates a new Heroku Git remote linked to the app.
-
Take generated remote URI and add it to git remote:
git remote add <remote-name> <remote-uri>
-
Check the added Git remotes:
git remote -v
- This will list all remotes in your local repository.
- Ensure the
heroku
remote is pointing to the correct Heroku app repository.
-
Set the Rails
master.key
on Heroku: Themaster.key
is required to decrypt thecredentials.yml.enc
file during runtime. Add it to Heroku using the following command:heroku config:set RAILS_MASTER_KEY=$(cat config/master.key) --remote <remote-name>
-
Push your local project to Heroku:
git push <remote-name> main
After deploying your app to Heroku, you need to configure the OAuth redirect URL in the Google Developer Console to enable Google OmniAuth authentication.
-
Obtain your Heroku app's deployment URL:
- After deploying your app, Heroku generates a URL in the format:
https://<your-heroku-app-name>.herokuapp.com
- After deploying your app, Heroku generates a URL in the format:
-
Add the URL to the Google Developer Console:
- Go to the Google Cloud Console.
- Navigate to APIs & Services > Credentials.
- Select your OAuth 2.0 Client ID.
- Under the Authorized redirect URIs section, add the following:
https://<your-heroku-app-name>.herokuapp.com/auth/google_oauth2/callback
The deployed app will now use the configured redirect URL for Google OmniAuth authentication.
We will use Heroku Postgres to set up the database for the app.
-
You need to have a database provisioned for your application. Procure the following add-on and attach it to your heroku app - Heroku Postgres. (Choose the Essential-0 plan for minimal cost)
-
This will automatically provision the PostgreSQL database and configure the connection. To verify the database connection, check the DATABASE_URL config variable:
heroku config:get DATABASE_URL --remote <remote-name>
-
Migrate the database:
heroku run rake db:migrate --remote <remote-name>
Redis will be used for enabling real-time chats with the help of WebSockets. We will use the Heroku Key-Value Store add-on to set up Redis.
- You need to have a Heroku Key-Value Store provisioned for your application. Procure the following add-on and attach it to your heroku app - Heroku Key-Value Store. (Choose the mini plan for minimal cost)
- Check the configuration for Redis:
heroku config:get REDIS_URL --remote <remote-name>
- The corresponding configuration for Redis has been already added and can be found in
config/cable.yml
file. - After deploying your app to Heroku, you need to set the correct Action Cable URL and allowed request origins in the
config/environments/production.erb
file for WebSocket connections.- Open the
config/environments/production.erb
file in your Rails app. - Update
config.action_cable.url
andconfig.action_cable.allowed_request_origins
using the Heroku app URL. - Commit the changes the push the code to heroku remote.
- Open the
To check your app's logs, use the following command:
heroku logs --tail --remote <remote-name>
The Jimmy - Gym Buddy Finder app is now successfully deployed on Heroku with the necessary configurations for authentication, database, real-time chats, and image storage. Make sure to monitor and scale your app as needed using Heroku’s various add-ons and resources.
Name | |
---|---|
Kushal Lahoti | kushal.1170234@tamu.edu |
Yash Phatak | ysphatak@tamu.edu |
Mrunmay Deshmukh | mrunmayd@tamu.edu |
Barry Liu | barry89130663@tamu.edu |
Wei-Chien Cheng | wccheng@tamu.edu |
Chuan-Hsin Wang | chuanhsin0110@tamu.edu |
Kuan-Ru Huang | randy103104@tamu.edu |