Ruby on Rails with Sia and Auth0

Repository: ovrclk/akash-on-rails

This is an example Rails Pinterest clone hosted on Akash. There are a few extra features to make the most of decentralised hosting:

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 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}/auth/auth0/callback.
    • Logout URL: https://{yourdomain}.
    • 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

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.

footer-logo-dark

© Akash Network 2024 The Akash Network Authors Documentation Distributed under CC BY 4.0

Open-source Apache 2.0 Licensed.

GitHub v0.20.0

Privacy