Deploy Ruby on Rails on Hostim.dev
This guide shows how to deploy a Ruby on Rails app on Hostim.dev from a Git repository.
Quick start: Use the "Ruby on Rails Demo" template to skip the setup.
π Open the Console Click "+ New Project", pick Ruby on Rails Demo, and you're good to go.
Want to customize or start fresh? This guide walks you through the manual setup.
0. Create a Projectβ
Before deploying, create a new project:
- Go to your Hostim.dev dashboard
- Click Create Project
- Choose from:
- Scratch: start empty
- Template: use a prebuilt stack like Ruby on Rails Demo
- Docker Compose: paste your own Compose file
- For this guide, choose Scratch
- Name your project (e.g.
rails-demo) and click Create Project
1. Use the Example Rails Appβ
We'll deploy a real Rails app from our public repository:
π https://github.com/hostimdev/demo-rails
You only need to clone the code if you want to run it locally or check out how it works. In that case, follow the instructions in the project's README:
π³ This project already includes a working
Dockerfileand is ready to deploy out of the box.
2. Deploy on Hostim.devβ
β οΈ Order Matters: To ensure the app works correctly, create services in this order: Volume β Database β Redis β App.
2.1. Create a Volume for File Uploadsβ
- From your project dashboard, click Create Service β New Volume
- Name your volume (e.g.,
uploads) - Choose a plan
- Click Create Volume
2.2. Add a MySQL Databaseβ
- From your project dashboard, click Create Service β New MySQL
- Name your database (e.g.,
db) - Choose a plan
- Click Create MySQL
2.3. Add a Redis Instanceβ
- From your project dashboard, click Create Service β New Redis
- Name your Redis instance (e.g.,
redis) - Choose a plan
- Click Create Redis
2.4. Create the Rails Appβ
- From your project dashboard, click Create Service β New App
- Choose Git as the deployment type
- Use the GitHub URL:
https://github.com/hostimdev/demo-rails - Set the branch to
main - Leave Dockerfile path as
Dockerfile - Choose a plan and number of replicas
- Under Volume Mounts, click Attach Volume
- Select the volume you created (e.g.,
uploads) - Set mount path to
/rails/public/uploads
- Select the volume you created (e.g.,
- Check "Does this app have HTTP Service?"
- Set the HTTP Port to
3000 - Check "Is this app public?" (or leave unchecked for private access)
- Click Create App
2.5. Configure Environment Variablesβ
- Open your app in the dashboard
- Go to the Envs tab
- Add the following environment variables:
RAILS_ENV=development
DATABASE_HOST=$(DB_MYSQL_HOST)
DATABASE_USERNAME=$(DB_MYSQL_USER)
DATABASE_PASSWORD=$(DB_MYSQL_PASSWORD)
DATABASE_NAME=$(DB_MYSQL_DATABASE)
REDIS_URL=redis://$(REDIS_REDIS_HOST):$(REDIS_REDIS_PORT)
These pull in values automatically from the other services you set up.
| Variable | Description |
|---|---|
DATABASE_* | Populated from the MySQL service |
REDIS_URL | Populated from the Redis service |
RAILS_ENV | Set manually to development |
Click Save Changes when done.