Skip to content

vanderoost/blendergrid-on-rails

Repository files navigation

Blendergrid on Rails CI

A proof of concept re-write of the Blendergrid.com Web App in Rails.

Check the Demo Screencast Demo Screencast

Live at: blendergrid.com

Versions

  • Rails version: 8.0.2
  • Ruby version: 3.4.2

Configuration

Make sure the EDITOR environment variable is set (export EDITOR=vim).

Update credentials and secrets in the default credentials file:

RAILS_ENV=production bin/rails credentials:edit

For development credentials, use:

rails credentials:edit -e development

Database

Creation

Locally:

rails db:create

In production, Kamal takes care of this.

Initialization

Run bin/setup to create the database and initialize the test database.

Import old database

Make sure the MySQL gem is installed before running the ETL rake tasks.

RAILS_ENV=production ENABLE_OLD_DATABASE=true caffeinate -id bin/rake etl:users

Migrating changes in production

RAILS_ENV=production rails db:migrate

How to run the test suite

One off tests:

rails test

Automatic testing on code changes:

autotest

Running locally

Server

Running a local server (using foreman for both web and tailwind refreshes)

bin/dev

Email

Use Mailhog to run a local SMTP server.

To install Mailhog:

brew install mailhog

Then run mailhog, and open http://localhost:8025 in your browser to see the inbox.

Stripe

Make sure Stripe CLI is installed:

brew install stripe

Then run the webhook listener / forwarder for making Webhooks in the Sandbox work:

stripe listen --forward-to localhost:3000/webhooks/stripe_events

TODO: Maybe make this a command in bin/ and/or run it automatically on bin/dev?

Services (job queues, cache servers, search engines, etc.)

For running websockets locally, you need to have Redis installed.

Mac:

brew install redis

Linux:

sudo apt-get install redis-server

Rubocop

Sometimes Rubocop will not start up after being updated because the server of an old version is still running. To stop the server, run:

bundle exec rubocop --stop-server

Deployment instructions

Make sure the infrastructure is up and running.

infra

Manual deployment:

kamal deploy

Pushing to main will also trigger a deployment, configured in .github/workflows/ci.yml.

Nuking the server and starting from scratch

bin/kamal remove -y && \
ssh ubuntu@blendergrid.com \
  'docker volume rm $(docker volume ls -q | grep blendergrid)' && \
bin/kamal setup

API Security

The API uses tokens to authenticate requests (from the Swarm Engine for example).

A new token can be generated with:

rails api_tokens:generate[<name>] # Locally
RAILS_ENV=production rails api_tokens:generate[<name>] # In production

Monitoring

Live tailing production logs:

kamal logs

Opening a shell in the web app Docker container:

kamal shell

Running a console

Locally:

rails console

In production:

kamal console

Affiliates

Inviting users with credit

In order to invite users with a pre-made account that has a render credit balance, you can run:

kamal app exec --interactive --reuse "bin/rails users:invite"

TODO: Maybe ditch --reuse

Creating affiliate landing pages

You can create a landing page for a certain User account with:

kamal app exec --interactive 'bin/rails affiliates:create'

About

blendergrid-on-rails

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors