Skip to main content

Introduction

This guide covers deploying Ruby on Rails applications on Shard Cloud. Rails is a full-stack web framework for Ruby that emphasizes convention over configuration and rapid development.

Creating Your Project

Ensure you have Ruby and Rails installed.

Creating a New Rails Project

rails new my_rails_app
cd my_rails_app

Basic Application Structure

Your Rails application should have this structure:
my_rails_app/
├── app/
│   ├── controllers/
│   ├── models/
│   └── views/
├── bin/
├── config/
├── db/
├── lib/
├── public/
├── Gemfile
└── .shardcloud

Configuring Port 80

Update config/puma.rb to use port 80:
config/puma.rb
port ENV.fetch("PORT") { 80 }
Or bind to all interfaces:
config/puma.rb
bind "tcp://0.0.0.0:#{ENV.fetch('PORT') { 80 }}"

Shard Cloud Configuration

Create a .shardcloud file:
.shardcloud
DISPLAY_NAME=Rails Website
DESCRIPTION=Ruby on Rails Application
MAIN=Gemfile
MEMORY=512
VERSION=recommended
SUBDOMAIN=my-rails-site
CUSTOM_COMMAND=chmod +x bin/rails && bin/rails server -b 0.0.0.0
The CUSTOM_COMMAND makes the Rails binary executable and starts the server bound to all interfaces.

Deploying

1

Verify Locally

Run bin/rails server to verify your application works locally.
2

Prepare Your Files

Ensure you have:
  • All source files (app/, config/, db/, lib/, public/)
  • bin/ folder (contains Rails executables)
  • Gemfile
  • .shardcloud
3

Exclude Unnecessary Files

Remove:
  • vendor/bundle/
  • .bundle/
  • tmp/
  • log/
  • node_modules/ (if present)
4

Create ZIP Archive

Zip the entire Rails application folder.
5

Upload to Shard Cloud

Go to Shard Cloud Dashboard and upload.

Database Configuration

If your Rails app uses a database, configure it in config/database.yml:
config/database.yml
production:
  adapter: postgresql
  url: <%= ENV['DATABASE_URL'] %>
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
Set the DATABASE_URL environment variable in your Shard Cloud dashboard.

Running Migrations

You can run migrations by updating your custom command:
.shardcloud
CUSTOM_COMMAND=chmod +x bin/rails && bin/rails db:migrate && bin/rails server -b 0.0.0.0

Additional Resources

Visit the official Rails documentation for more information.

Troubleshooting

The chmod +x bin/rails in CUSTOM_COMMAND should fix this. Make sure the bin/ folder is included in your ZIP.
  • Make sure Gemfile includes all required gems
  • Remove vendor/bundle/ folder before uploading (Shard Cloud will install gems)
  • Precompile assets before uploading: bin/rails assets:precompile
  • Or add to CUSTOM_COMMAND: bin/rails assets:precompile && bin/rails server -b 0.0.0.0
  • Verify DATABASE_URL environment variable is set in dashboard
  • Ensure config/database.yml reads from environment variables
  • Ensure -b 0.0.0.0 is included to bind to all interfaces
  • Check that port 80 is configured in config/puma.rb