A proof of concept re-write of the Blendergrid.com Web App in Rails.
Live at: blendergrid.com
- Rails version: 8.0.2
- Ruby version: 3.4.2
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:editFor development credentials, use:
rails credentials:edit -e developmentLocally:
rails db:createIn production, Kamal takes care of this.
Run bin/setup to create the database and initialize the test 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:usersRAILS_ENV=production rails db:migrateOne off tests:
rails testAutomatic testing on code changes:
autotestRunning a local server (using foreman for both web and tailwind refreshes)
bin/devUse Mailhog to run a local SMTP server.
To install Mailhog:
brew install mailhogThen run mailhog, and open http://localhost:8025 in your browser to see the inbox.
Make sure Stripe CLI is installed:
brew install stripeThen run the webhook listener / forwarder for making Webhooks in the Sandbox work:
stripe listen --forward-to localhost:3000/webhooks/stripe_eventsTODO: Maybe make this a command in bin/ and/or run it automatically on bin/dev?
For running websockets locally, you need to have Redis installed.
Mac:
brew install redisLinux:
sudo apt-get install redis-serverSometimes 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-serverMake sure the infrastructure is up and running.
infraManual deployment:
kamal deployPushing to main will also trigger a deployment, configured in .github/workflows/ci.yml.
bin/kamal remove -y && \
ssh ubuntu@blendergrid.com \
'docker volume rm $(docker volume ls -q | grep blendergrid)' && \
bin/kamal setupThe 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 productionLive tailing production logs:
kamal logsOpening a shell in the web app Docker container:
kamal shellLocally:
rails consoleIn production:
kamal consoleIn 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
You can create a landing page for a certain User account with:
kamal app exec --interactive 'bin/rails affiliates:create'