{"id":45842,"date":"2016-03-24T22:00:54","date_gmt":"2016-03-24T19:00:54","guid":{"rendered":"https:\/\/www.altoros.com\/blog\/?p=45842"},"modified":"2019-08-07T15:42:31","modified_gmt":"2019-08-07T12:42:31","slug":"deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix","status":"publish","type":"post","link":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/","title":{"rendered":"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-rails5-mongodb-object-storage-redis-v2.png\" alt=\"ibm-bluemix-rails5-mongodb-object-storage-redis-v2\" width=\"180\" style=\"margin: 0px 0px 0px 15px;\" class=\"alignright size-full wp-image-45843\" \/><\/p>\n<p>In this post, we show how to deploy a Rails 5 application with MongoDB as a database and CarrierWave for image processing to Bluemix. The source code for the article is available in <a href=\"https:\/\/github.com\/dimoon\/rails-bluemix-blog\" target=\"_blank\" rel=\"noopener noreferrer\">this GitHub repo<\/a>.<\/p>\n<p>Please keep in mind one slight difference: in the article, credentials are set in a more explicit way with user-defined environment variables, while in the repository, they are fetched from the Cloud Foundry application auto-generated <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">VCAP_SERVICES<\/code> variable.<\/p>\n<p>&nbsp;<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Adding_and_configuring_services\" >Adding and configuring services<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Adding_services_through_the_CLI\" >Adding services through the CLI<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Adding_services_through_the_UI\" >Adding services through the UI<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Manifestyml\" >Manifest.yml<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Deploying_the_application\" >Deploying the application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#Further_reading\" >Further reading<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#About_the_authors\" >About the authors<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To follow the steps of this tutorial, you need:<\/p>\n<ul>\n<li>a Bluemix account<\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cf<\/code><\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">swift<\/code> (a Python client)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Adding_and_configuring_services\"><\/span>Adding and configuring services<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Before deploying, you need to create services instances for your application. You can do it through the <a href=\"https:\/\/cloud.ibm.com\/docs\/starters\/install_cli.html\" target=\"_blank\" rel=\"noopener noreferrer\">CLI<\/a> or the <a href=\"https:\/\/cloud.ibm.com\/catalog\/\" target=\"_blank\" rel=\"noopener noreferrer\">UI<\/a>. Note that a free MongoDB service hosted by Bluemix is not available in the UI. In addition, some configuration options have to be specified in the <a href=\"https:\/\/docs.cloudfoundry.org\/devguide\/deploy-apps\/manifest.html\" target=\"_blank\" rel=\"noopener noreferrer\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">manifest.yml<\/code><\/a> file.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Adding_services_through_the_CLI\"><\/span>Adding services through the CLI<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The organization you intend to use and the space within it should be created in the Bluemix UI before you authenticate with <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cf login<\/code>. They can have any names that you choose.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/adding-ibm-bluemix-services-via-cloud-foundry-cli-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/adding-ibm-bluemix-services-via-cloud-foundry-cli-v1.png\" alt=\"adding-ibm-bluemix-services-via-cloud-foundry-cli-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45844\" \/><\/a><\/center><\/p>\n<p>After creating a new service, you should bind it to your application as explained in the <a href=\"https:\/\/cloud.ibm.com\/docs\/services\/MongoDB\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">official Bluemix documentation<\/a>. Alternatively, you can specify dependencies names in <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">manifest.yml<\/code>, and then <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cf push<\/code> will do it for you.<\/p>\n<p>To add a service from the command line, use <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cf create-service<\/code>. Below, you will find its syntax.<\/p>\n<pre style=\"padding-left: 30px;\">cf create-service SERVICE PLAN SERVICE_INSTANCE<\/pre>\n<p>where:<\/p>\n<ul>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">SERVICE<\/code> is the service name.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">PLAN<\/code> is the service plan.<\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">SERVICE_INSTANCE<\/code> is the name of your service instance. It is an instance alias that is meaningful to you.<\/li>\n<\/ul>\n<p>For more information, please check out the <a href=\"https:\/\/docs.cloudfoundry.org\/devguide\/services\/managing-services.html\" target=\"_blank\" rel=\"noopener noreferrer\">official Cloud Foundry docs<\/a>.<\/p>\n<p>First, we need to set up our <a href=\"https:\/\/console.bluemix.net\/docs\/services\/MongoDB\/index.html#MongoDB\" target=\"_blank\" rel=\"noopener noreferrer\">MongoDB<\/a>.<\/p>\n<pre style=\"padding-left: 30px;\">cf create-service mongodb 100 mongodb01\r\ncf set-env APP-NAME DATABASE_URL \u201cYOUR_MONGODB_URI\u201d<\/pre>\n<p><\/p>\n<p>After that, configure the database connection in your <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">config\/mongoid.yml<\/code>.<\/p>\n<pre style=\"padding-left: 30px;\">...\r\nproduction:\r\n  clients:\r\n    default:\r\n      uri: &lt;%= ENV[\u2018DATABASE_URL\u2019] %&gt;<\/pre>\n<p><\/p>\n<p>We will also need the Object Storage service and Redis.<\/p>\n<pre style=\"padding-left: 30px;\"># Object Storage\r\ncf create-service Object-Storage Free ostorage01\r\ncf set-env APP_NAME OSTORAGE_CREDENTIALS \u2018{\u201cauth_url\u201d:...}\u2019 # Get credentials from the Bluemix console.\r\n\r\n# Redis\r\ncf create-service rediscloud 30mb redis01\r\ncf set-env APP_NAME REDIS_URL \"http:\/\/rediscloud:password@hostname:port\"<\/pre>\n<p><\/p>\n<p>If you store the Object Storage credentials in an environment variable as described above, your CarrierWave initializer should look similar to the one in this example. Note that you should choose the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">fog-openstack<\/code> gem version 0.1.2 or later to use Bluemix Object Storage in your application.<\/p>\n<pre style=\"padding-left: 30px;\">config\/initializers\/carrierwave.rb:\r\n\r\nCarrierWave.configure do |config|\r\n  if Rails.env.production?\r\n    creds = JSON.parse(ENV['OSTORAGE_CREDENTIALS'])\r\n    config.storage = :fog\r\n    config.fog_credentials = {\r\n      provider:               'OpenStack',\r\n      openstack_auth_url:     creds['auth_url'] + '\/v3\/auth\/tokens',\r\n      openstack_api_key:      creds['password'],\r\n      openstack_project_id:   creds['projectId'],\r\n      openstack_userid:       creds['userId'],\r\n      openstack_region:       creds['region'],\r\n      openstack_temp_url_key: ENV['OS_TEMP_URL_KEY'],\r\n      openstack_auth_omit_default_port: true\r\n    }\r\n    config.fog_directory  = 'your_ostorage_container_name'\r\n    config.fog_public     = false\r\n    config.fog_authenticated_url_expiration = 600\r\n  end\r\nend\r\n<\/pre>\n<p><\/p>\n<p>As we use MongoDB instead of PostgreSQL, we have to provide <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">ActionCable<\/code> with Redis configuration. The following configuration file addresses this issue as shown below.<\/p>\n<pre style=\"padding-left: 30px;\">config\/cable.yml:\r\n\r\nproduction:\r\n  adapter: redis\r\n  url: &lt;%= ENV[\u2018REDIS_URL\u2019] %&gt;<\/pre>\n<p>To use Object Storage, you need to create a container and set <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">fog_directory<\/code> to its name. You also need <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">TEMP_URL_KEY<\/code>\u2014a random secret string\u2014to generate public URLs for your images. To do so, run the following commands.<\/p>\n<pre style=\"padding-left: 30px;\">swift --os-auth-url 'https:\/\/identity.open.softlayer.com\/v3' --auth-version 3 --os-project-id PROJECT_ID --os-region REGION --os-user-id USER_ID --os-password PASSWORD post -m 'Temp-URL-Key:YOUR_KEY'\r\ncf set-env APP_NAME OS_TEMP_URL_KEY YOUR_KEY<\/pre>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Adding_services_through_the_UI\"><\/span>Adding services through the UI<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Note that sometimes you  can choose between different offerings for the same tool in the Bluemix services catalog. For example, you have two options for Redis: Redis Cloud and Redis by Compose.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/adding-ibm-bluemix-services-via-ui-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/adding-ibm-bluemix-services-via-ui-v1.png\" alt=\"adding-ibm-bluemix-services-via-ui-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45845\" \/><\/a><\/center><\/p>\n<p>The last one gives you a configuration that is pretuned for high availability, includes additional security features, and also provides a number of metrics. The same is true for MongoDB.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-mongodb-metrics-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-mongodb-metrics-v1.png\" alt=\"ibm-bluemix-mongodb-metrics-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45846\" \/><\/a><small>MongoDB Compose metrics<\/small><\/center><\/p>\n<p>After you create all the services, you should set the environment variables\u2014<code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">DATABASE_URL<\/code>, <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">REDIS_URL<\/code>, <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">OSTORAGE_CREDENTIALS<\/code>, and <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">OS_TEMP_URL_KEY<\/code>\u2014according to their credentials.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-mongodb-redis-environment-variables-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-mongodb-redis-environment-variables-v1.png\" alt=\"ibm-bluemix-mongodb-redis-environment-variables-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45847\" \/><\/a><small>Setting environment variables in the Bluemix UI<\/small><\/center><\/p>\n<p>Below, you can also see an example of reading service credentials.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-mongodb-object-storage-credentials-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/ibm-bluemix-mongodb-object-storage-credentials-v1.png\" alt=\"ibm-bluemix-mongodb-object-storage-credentials-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45848\" \/><\/a><small>Reading services credentials on the Bluemix website<\/small><\/center><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Manifestyml\"><\/span>Manifest.yml<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">manifest.yml<\/code> file consists of two sections. The first section\u2014<code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">declared-services<\/code>\u2014describes services that an application uses. Below, you will find this very section for the sample application.<\/p>\n<pre style=\"padding-left: 30px;\">declared-services:\r\n  mongodb01:\r\n    label: Rails 5 blog MongoDB\r\n    plan: 100\r\n  ostorage01:\r\n    label: Rails 5 blog Object Storage\r\n    plan: Free\r\n  redis01:\r\n    label: Rails 5 blog Redis\r\n    plan: 30mb<\/pre>\n<p><\/p>\n<p>The keys are the names of the services that are to be referenced later. The values specify the services labels and plans.<\/p>\n<p>The second section\u2014<code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">applications<\/code>\u2014describes the application itself. Here is this section for the sample application with the properties defined below.<\/p>\n<pre style=\"padding-left: 30px;\">applications:\r\n- name: rails-5-blog\r\n  memory: 256M\r\n  instances: 1\r\n  path: .\r\n  stack: cflinuxfs2\r\n  buildpack: https:\/\/github.com\/ddollar\/heroku-buildpack-multi.git\r\n  command: bundle exec puma -e production -p $PORT\r\n  services:\r\n    - mongodb01\r\n    - ostorage01\r\n    - redis01<\/pre>\n<p>where:<\/p>\n<ul>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">name<\/code> is the application name as it is shown in your Bluemix console.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">memory<\/code> is the amount of RAM that is reserved per a single instance of the application excluding services.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">instances<\/code> is the number of instances to start.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">path<\/code> is a relative path to the project that is deployed. It can be a folder for Ruby or, for example, a <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">war<\/code>\/<code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">jar<\/code> file for Java.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">stack<\/code> is the Cloud Foundry image for the application. The <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cflinuxfs2<\/code> image is based on Ubuntu 14.04 (Trusty), and it is the most common choice for Ruby applications.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">buildpack<\/code> is a Git or local path to the used buildpack. For plain Ruby applications, it is typically <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">https:\/\/github.com\/cloudfoundry\/ruby-buildpack.git<\/code>. To use <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">wkhtmltopdf<\/code> in the example, we refer to the buildpack that lets to specify multiple buildpacks for a single application. In this case, the used buildpacks are included in  the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">.buildpacks<\/code> file.<\/li>\n<li style=\"margin-bottom: 6px;\"><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">command<\/code> defines what command to run to start the application. It has to be a foreground program, and the default start timeout is 60 seconds. Note that your application should listen to the port specified with the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">$PORT<\/code> environment variable and not to the port 80 that is used as an upstream for the NGINX server.<\/li>\n<li><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">services<\/code> lists the names of all services bound to the application. These services should be described in the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">declared-services<\/code> section mentioned above.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Deploying_the_application\"><\/span>Deploying the application<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To deploy, you can just go to your application directory and run <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cf push<\/code>. (Of course, you need to use <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">cf login<\/code> for the first time.) For real-world applications, you might need something more powerful:<\/p>\n<ul>\n<li><a href=\"https:\/\/hub.jazz.net\/tutorials\/jazzeditor\/#git_integration_and_autodeployment\" target=\"_blank\" rel=\"noopener noreferrer\">Git integration<\/a> and <a href=\"https:\/\/hub.jazz.net\/docs\/githubhooks\/#github_hook\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub hooks<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=3OHMrr8iz5E\" target=\"_blank\" rel=\"noopener noreferrer\">Auto-deployment with DevOps Services<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/continuous-integration-and-continuous-delivery-in-ibm-bluemix\/\">Continuous Integration and Continuous Delivery<\/a>, etc.<\/li>\n<\/ul>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/build-and-deploy-in-ibm-bluemix-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/build-and-deploy-in-ibm-bluemix-v1.png\" alt=\"build-and-deploy-in-ibm-bluemix-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45850\" \/><\/a><small>Build and deploy in Bluemix<\/small><\/center><\/p>\n<p>When using the CLI, you will get the result as shown below.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/cloud-foundry-cli-cf-push-result-v1.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/08\/cloud-foundry-cli-cf-push-result-v1.png\" alt=\"cloud-foundry-cli-cf-push-result-v1\" width=\"640\" class=\"aligncenter size-full wp-image-45849\" \/><\/a><\/center><\/p>\n<p>If you want to use background jobs in your Rails application, check out the official <a href=\"https:\/\/docs.cloudfoundry.org\/buildpacks\/ruby\/ruby-tips.html#workers\" target=\"_blank\" rel=\"noopener noreferrer\">Cloud Foundry docs<\/a>. Notice that your application needs to be deployed twice in this case.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Further_reading\"><\/span>Further reading<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/getting-started-with-ibm-bluemix-deploying-a-sample-ruby-sinatra-app\/\">Getting Started with IBM Bluemix: Deploying a Sample Ruby\/Sinatra App<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/continuous-integration-and-continuous-delivery-in-ibm-bluemix\/\">Continuous Integration and Continuous Delivery in IBM Bluemix<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/the-ibm-bluemix-object-storage-service-in-ruby-projects\/\">Using IBM Bluemix Object Storage in Ruby Projects<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-app-with-elasticsearch-to-ibm-bluemix\/\">Deploying a Rails App with Elasticsearch to IBM Bluemix<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/using-the-bluemix-insights-for-twitter-service-with-a-rails-app\/\">Using the Bluemix Insights for Twitter Service with a Rails App<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"About_the_authors\"><\/span>About the authors<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><small><a href=\"https:\/\/github.com\/gekola\" target=\"_blank\" rel=\"noopener noreferrer\">Nick Herman<\/a> is a software engineer at Altoros. He specializes in web development using Ruby and JavaScript as his primary tools. Nick also has professional interests and expertise in many other areas related to software engineering, including programming languages and cloud technologies.<\/small><\/p>\n<p><small><strong>Dzmitry Bardziyan<\/strong> is a Ruby and JavaScript developer at Altoros. He has solid knowledge of Rackspace, AWS, SoftLayer, vSphere, and other infrastructure solutions, as well as background in system administration. Dzmitry also contributes to a number of IT magazines.<\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<\/p>\n<p>In this post, we show how to deploy a Rails 5 application with MongoDB as a database and CarrierWave for image processing to Bluemix. The source code for the article is available in this GitHub repo.<\/p>\n<p>Please keep in mind one slight difference: in the article, credentials are set in a [&#8230;]<\/p>\n","protected":false},"author":78,"featured_media":45857,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[214],"tags":[873,187,206],"class_list":["post-45842","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-cloud-native","tag-ibm-bluemix","tag-oss-cloud-foundry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix | Altoros<\/title>\n<meta name=\"description\" content=\"Learn how to add and configure services step by step via the CLI or the UI.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix | Altoros\" \/>\n<meta property=\"og:description\" content=\"In this post, we show how to deploy a Rails 5 application with MongoDB as a database and CarrierWave for image processing to Bluemix. The source code for the article is available in this GitHub repo. Please keep in mind one slight difference: in the article, credentials are set in a [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/\" \/>\n<meta property=\"og:site_name\" content=\"Altoros\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-24T19:00:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-07T12:42:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/gif\" \/>\n<meta name=\"author\" content=\"Nick Herman\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nick Herman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/\",\"name\":\"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix | Altoros\",\"isPartOf\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif\",\"datePublished\":\"2016-03-24T19:00:54+00:00\",\"dateModified\":\"2019-08-07T12:42:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/f18d50b9edfbcdc995be899e3edb42ff\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#primaryimage\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif\",\"width\":640,\"height\":360},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.altoros.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\",\"url\":\"https:\/\/www.altoros.com\/blog\/\",\"name\":\"Altoros\",\"description\":\"Insight\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.altoros.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/f18d50b9edfbcdc995be899e3edb42ff\",\"name\":\"Nick Herman\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/12\/328df9f-150x150.jpg\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/12\/328df9f-150x150.jpg\",\"caption\":\"Nick Herman\"},\"description\":\"Nick Herman is a software engineer at Altoros. He specializes in web development using Ruby and JavaScript as his primary tools. Nick also has professional interests and expertise in many other areas related to software engineering, including programming languages and cloud technologies. You can find him on GitHub.\",\"url\":\"https:\/\/www.altoros.com\/blog\/author\/nick-herman\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix | Altoros","description":"Learn how to add and configure services step by step via the CLI or the UI.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/","og_locale":"en_US","og_type":"article","og_title":"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix | Altoros","og_description":"In this post, we show how to deploy a Rails 5 application with MongoDB as a database and CarrierWave for image processing to Bluemix. The source code for the article is available in this GitHub repo. Please keep in mind one slight difference: in the article, credentials are set in a [...]","og_url":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/","og_site_name":"Altoros","article_published_time":"2016-03-24T19:00:54+00:00","article_modified_time":"2019-08-07T12:42:31+00:00","og_image":[{"width":640,"height":360,"url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif","type":"image\/gif"}],"author":"Nick Herman","twitter_misc":{"Written by":"Nick Herman","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/","url":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/","name":"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix | Altoros","isPartOf":{"@id":"https:\/\/www.altoros.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#primaryimage"},"image":{"@id":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#primaryimage"},"thumbnailUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif","datePublished":"2016-03-24T19:00:54+00:00","dateModified":"2019-08-07T12:42:31+00:00","author":{"@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/f18d50b9edfbcdc995be899e3edb42ff"},"breadcrumb":{"@id":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#primaryimage","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/03\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix-v1.gif","width":640,"height":360},{"@type":"BreadcrumbList","@id":"https:\/\/www.altoros.com\/blog\/deploying-a-rails-5-app-with-mongodb-redis-and-carrierwave-to-ibm-bluemix\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.altoros.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Deploying a Rails 5 App with MongoDB, Redis, and CarrierWave to IBM Bluemix"}]},{"@type":"WebSite","@id":"https:\/\/www.altoros.com\/blog\/#website","url":"https:\/\/www.altoros.com\/blog\/","name":"Altoros","description":"Insight","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.altoros.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/f18d50b9edfbcdc995be899e3edb42ff","name":"Nick Herman","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/12\/328df9f-150x150.jpg","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/12\/328df9f-150x150.jpg","caption":"Nick Herman"},"description":"Nick Herman is a software engineer at Altoros. He specializes in web development using Ruby and JavaScript as his primary tools. Nick also has professional interests and expertise in many other areas related to software engineering, including programming languages and cloud technologies. You can find him on GitHub.","url":"https:\/\/www.altoros.com\/blog\/author\/nick-herman\/"}]}},"_links":{"self":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/45842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/comments?post=45842"}],"version-history":[{"count":7,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/45842\/revisions"}],"predecessor-version":[{"id":45858,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/45842\/revisions\/45858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media\/45857"}],"wp:attachment":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media?parent=45842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/categories?post=45842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/tags?post=45842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}