diff --git a/docs/create/heroku/herokuruby/create_heroku.png b/docs/create/heroku/herokuruby/create_heroku.png new file mode 100644 index 0000000000..68d7813f4d Binary files /dev/null and b/docs/create/heroku/herokuruby/create_heroku.png differ diff --git a/docs/create/heroku/herokuruby/heroku_app1_env.png b/docs/create/heroku/herokuruby/heroku_app1_env.png new file mode 100644 index 0000000000..b30b5307b3 Binary files /dev/null and b/docs/create/heroku/herokuruby/heroku_app1_env.png differ diff --git a/docs/create/heroku/herokuruby/heroku_leaderboard_ruby.png b/docs/create/heroku/herokuruby/heroku_leaderboard_ruby.png new file mode 100644 index 0000000000..cd62ee8477 Binary files /dev/null and b/docs/create/heroku/herokuruby/heroku_leaderboard_ruby.png differ diff --git a/docs/create/heroku/herokuruby/index-herokuruby.mdx b/docs/create/heroku/herokuruby/index-herokuruby.mdx new file mode 100644 index 0000000000..d27d4c8440 --- /dev/null +++ b/docs/create/heroku/herokuruby/index-herokuruby.mdx @@ -0,0 +1,202 @@ +--- +id: index-herokuruby +title: Deploy a Ruby app on Heroku using Redis +sidebar_label: How to deploy a Ruby based application on Heroku using Redis +slug: /create/heroku/herokuruby +authors: [ajeet] +--- + +import RedisCard from '@site/src/theme/RedisCard'; + +Heroku is a popular PaaS offering that allows software developers to easily deploy their code without worrying about the underlying infrastructure. By using a simple 'git push heroku' command, developers are able to deploy their application flawlessly. This platform offers support for a wide range of programming languages such as Java, Ruby, PHP, Node.js, Python, Scala, and Clojure. + +Here's a quickstart guide to deploy Ruby apps on Heroku using Redis. We will be deploying a sample Leaderboard app and will be using company valuation and stock tickers as its domain. + + +### Step 1. Create a Redis Enterprise Cloud Database + +Create your free Redis Enterprise Cloud account by visiting [this link](https://redis.com/try-free). + + + +[Follow this link to create a Redis Enterprise Cloud](/create/rediscloud) subscription and database as shown below: + + + + +The database endpoint URL is unique so will be different in your case. Save it for future reference. + + + +### Step 2. Create a Heroku account + +If you are using Heroku for the first time, create your new Heroku account [through this link](https://signup.heroku.com/login). + + + + +### Step 3. Install the Heroku CLI on your system + + ```macos + brew install heroku + ``` + +### Step 4. Login to Heroku + + ```bash + heroku login + heroku: Press any key to open up the browser to login or q to exit: + Opening browser to https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA + Logging in... done + Logged in as your_email_address + ``` + +### Step 5. Connect your application to Redis Enterprise Cloud + +For this demonstration, we will be using a [Sample Redis Leaderboard app](https://github.com/redis-developer/basic-redis-leaderboard-demo-ruby). + +#### Clone the repository + + ```bash + git clone https://github.com/redis-developer/basic-redis-leaderboard-demo-ruby + ``` + + + +Run the commands below to get a functioning Git repository that contains a simple application as well as a `package.json` file. + + +``` +heroku create +Creating app... done, ⬢ thawing-shore-07338 +https://thawing-shore-07338.herokuapp.com/ | https://git.heroku.com/thawing-shore-07338.git +``` + + + +### Step 6. Setting up Environment Variables + +Go to the Heroku dashboard, click "Settings" and set `REDIS_HOST` and `REDIS_PASSWORD` under the Config Vars. +Refer to Step 1 for the correct values to use. + + + + + +You now have a functioning Git repository that contains a simple application as well as a `package.json` file, which is used by Node’s dependency manager. + + + + +### Step 7. Deploy your code + + +``` +$ git push heroku +``` + +Wait for few seconds and you will see the messages below: + +``` +remote: -----> Discovering process types +remote: Procfile declares types -> (none) +remote: Default types for buildpack -> console, rake, web +remote: +remote: -----> Compressing... +remote: Done: 125.9M +remote: -----> Launching... +remote: Released v10 +remote: https://thawing-shore-07338.herokuapp.com/ deployed to Heroku +remote: +remote: Verifying deploy... done. +To https://git.heroku.com/thawing-shore-07338.git + * [new branch] master -> master +``` + +### Step 8. Accessing the application + + +Open https://thawing-shore-07338.herokuapp.com/ to access your application on the browser. +Please note that the Web URL is unique, hence it will be different in your case. + + + +### How does it work? + + +#### How the data is stored: + +- The AAPL's details - market cap of 2.6 triillions and USA origin - are stored in a Redis hash like this: + ```bash + HSET "company:AAPL" symbol "AAPL" market_cap "2600000000000" country USA + ``` + +- The market capitalization for each company is also stored in a ZSET (Redis Sorted Set). + + ```bash + ZADD companyLeaderboard 2600000000000 company:AAPL + ``` + +#### How the data is accessed: + +- Top 10 companies: + + ```bash + ZREVRANGE companyLeaderboard 0 9 WITHSCORES + ``` + +- All companies: + + ```bash + ZREVRANGE companyLeaderboard 0 -1 WITHSCORES + ``` + +- Bottom 10 companies: + + ```bash + ZRANGE companyLeaderboard 0 9 WITHSCORES + ``` + +- Between rank 10 and 15: + + ```bash + ZREVRANGE companyLeaderboard 9 14 WITHSCORES + ``` + +- Show rank for AAPL, FB and TSLA: + + ```bash + ZREVRANGE companyLeaderBoard company:AAPL company:FB company:TSLA + ``` + +- Add 1 billion to the market cap of the FB company: + + ```bash + ZINCRBY companyLeaderBoard 1000000000 "company:FB" + ``` + +- Reduce the market cap of the FB company by 1 billion: + + ```bash + ZINCRBY companyLeaderBoard -1000000000 "company:FB" + ``` + +- How many companies have a market cap between 500 billion and 1 trillion?: + + ```bash + ZCOUNT companyLeaderBoard 500000000000 1000000000000 + ``` + +- How many companies have a market cap over a Trillion?: + + ```bash + ZCOUNT companyLeaderBoard 1000000000000 +inf + ``` + + +### Next Steps + +- [Connecting to the database using RedisInsight](/explore/redisinsight/) +- [Accessing Ruby-based apps over Redis LaunchPad](https://launchpad.redis.com/) +- [Deploy Java apps on Heroku using Redis](/create/heroku/herokujava) +- [Deploy NodeJS apps on Heroku using Redis](/create/heroku/herokujava) diff --git a/docs/create/heroku/herokuruby/launch_database.png b/docs/create/heroku/herokuruby/launch_database.png new file mode 100644 index 0000000000..67d35afa3b Binary files /dev/null and b/docs/create/heroku/herokuruby/launch_database.png differ diff --git a/docs/create/heroku/herokuruby/try-free.png b/docs/create/heroku/herokuruby/try-free.png new file mode 100644 index 0000000000..11915ea592 Binary files /dev/null and b/docs/create/heroku/herokuruby/try-free.png differ diff --git a/docs/create/heroku/index-heroku.mdx b/docs/create/heroku/index-heroku.mdx index 6c3b5b3211..8eae0281a9 100644 --- a/docs/create/heroku/index-heroku.mdx +++ b/docs/create/heroku/index-heroku.mdx @@ -48,4 +48,13 @@ The following links provide you with the available options to run apps on Heroku page="/create/heroku/ratelimiting-go" /> + +