Community
Live Chat
Careers
Support
Search…
Akash Guidebook
Intro to Akash
Tokens and Wallets
Deployments
Integrations
TLS Termination of Akash Deployments
Chia on Akash
Polygon on Akash
Mine Raptoreum on Akash Network
Unstoppable Web 2.0
Multi-Tiered Deployment
Helium Validator
PostgreSQL restore/backup
Ruby on Rails with Sia and Auth0
Providers
Akash Nodes
Validating
Command Line
Features
Other Resources
Powered By
GitBook
Ruby on Rails with Sia and Auth0
Repository
:
ovrclk/akash-on-rails
Demo
:
pin.akash.host
​
This is an example Rails Pinterest clone hosted on Akash. There are a few extra features to make the most of decentralised hosting:
Database backup/restore to
Sia
via
Filebase
.
User image uploads to
Sia
via
Filebase
.
​
Auth0
user authentication.
​
Cloudflare
DNS and SSL.
Scheduled tasks using
Whenever
.
Architecture
App container
Runs the rails server and hosts the actual website.
Connects to the Postgres container for a persistent database.
Hosts files on
Filebase
(
Sia
,
Skynet
, and
Storj
hosting currently).
Uses
Auth0
for user login and registration.
Cron container
Auto-restores the Postgres database on boot, achieving persistent database through re-deploys.
Auto-backup of the database to
Filebase
every 15 minutes.
Crontab is defined using
Whenever
in
schedule.rb
.
Runs the same docker image as the rails application, but running
cron
instead of the rails server.
A
standalone database backup/restore container
is also available.
Postgres container
Runs a standard Postgres server docker image.
Usage
Ultimately this repository is designed to provide a sensible example of hosting a rails application on Akash. There are a few ways to use it:
Run the application as-is on Akash with your own storage and
Auth0
account
Setup a free
Cloudflare
account and add your domain and set nameservers.
Setup a
Filebase
account and bucket.
Add a
backups
folder to your bucket.
You will need your bucket name, client ID, and secret.
Sign up for an
Auth0
account and set up an App.
Callback URL:
https://yourdomain.com/auth/auth0/callback
.
Logout URL:
https://yourdomain.com
.
You will need your
Auth0
domain, client ID, and secret.
Using the example deploy.yml, populate the environment variables with the values from
Filebase
and
Auth0
.
Deploy on Akash and get your app URL.
Point your domain to your app URL using a CNAME in
Cloudflare
.
Configure 'Full' SSL mode in
Cloudflare
.
Sign in to your website using
Auth0
. The first user created will be made an administrator.
Use the relevant files in your own project
​
Dockerfile
​
Rails ready Dockerfile.
Installs the AWS CLI tool to interact with
Filebase
.
​
scripts/run-app.sh
​
Precompiles rails assets.
Runs the rails server.
​
scripts/run-scheduler.sh
​
Creates and restores the database.
Runs rake db:migrate and db:seed.
Sets the crontab using
Whenever
and runs the cron service.
​
scripts/restore-postgres.sh
​
Downloads latest backup from
Filebase
.
Restore the DB if a backup was found.
​
scripts/backup-postgres.sh
​
Backs up the database to
Filebase
.
Deletes backups older than KEEP_BACKUPS.
​
config/schedule.rb
​
​
Whenever
cron schedule file to run scripts/backup-postgres.sh every 15 minutes.
​
config/initializers/shrine.rb
​
Configures Shrine within the application to use
Filebase
as an S3 host.
​
deploy.yml
​
Akash deploy manifest.
Clone the repository and use it as a base for a new project
Clone the repository to your own Github account.
Rename any occurrence of AkashOnRails, akash-on-rails and, akash_on_rails to your own app name.
Change any app/models, app/controllers, app/views as required.
Development
You can run the application locally using Docker compose.
Copy the
.env.sample
file to
.env
and populate.
Run
docker-compose up
to build and run the application.
Previous
PostgreSQL restore/backup
Next
Providers
Last modified
1mo ago
Copy link
Contents
Architecture
App container
Cron container
Postgres container
Usage
Run the application as-is on Akash with your own storage and Auth0 account
Use the relevant files in your own project
Clone the repository and use it as a base for a new project
Development