Skip to content

Brock-Software/billing-saas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

A react, react-router, vite (w Remix plugin), using pre-v7 (remix & react-router are not merged pre-v7). See the package.json for standard commands.

Command Description
Package manager bun
Stack React, Remix (react-router as a framework), Vite
Apps 1) Web app (core), 2) backup db service, 3) queue-service (for handling jobs)

Getting started

  1. Create .env file & copy over all values from .env.example
  2. Install dependencies w/ bun install
  3. Migrate the database bunx prisma migrate dev
  4. Begin development with bun dev
  5. Open another terminal, and start the queue-service to handle jobs with bun run workers/queue-service.ts

Troubleshooting

Code Rollback

fly deploy -i `fly releases -j | jq ".[1].ImageRef" -r`

Run fly releases --image to see the latest images released if you need to cherry-pick. Only code changes will create a new image (setting or removing secrets won't create a new image, etc.)

Database security

Backups

All backups are automated (if the aws variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY are in github action secrets). They will happen daily.

Restore

To restore the latest database in case of emergency, run the following commands:

fly ssh console -C "./scripts/restore-latest-backup.sh"

Deploying for the first time

  • Launch your app on Fly with fly launch > Select 'y' to configure settings
    • In the browser popup, select the correct organization
    • Select 'n' when asked if you want to create a .dockerignore
    • Select 'save' (or 'confirm' or whatever)
    • Back in the terminal, exit the deployment with ctrl+c (we don't need to do this yet, we'll do it shortly)
  • Delete the Dockerfile that was created (we already have one in the other/ folder)
  • Setup the fly deploy token in Github
    • Create a new "Production" environment under Settings (if one doesn't already exist)
    • Create new environment secrets
      • FLY_AUTH_TOKEN = Run fly tokens create deploy in the terminal and use the output token
      • AWS_ACCESS_KEY_ID = Visit console.tigris.dev, create a bucket under the right org, and then create an Access Key - use the key id here, and save the value in the repo .env file
      • AWS_SECRET_ACCESS_KEY = See access key id instructions ^ - use the access secret key here, and save the value in the repo .env file
  • Setup Fly Secrets with fly secrets set (all secrets in your .env)
    • Required secrets: fly secrets set SESSION_SECRET=$(openssl rand -hex 32) INTERNAL_COMMAND_TOKEN=$(openssl rand -hex 32) HONEYPOT_SECRET=$(openssl rand -hex 32)
    • AWS Secrets: fly secrets set AWS_ACCESS_KEY_ID=<value_from_prev_step> AWS_SECRET_ACCESS_KEY=<value_from_prev_step>
    • Add any extra secrets you need
  • Deploy your app with fly deploy (or push to main)
  • Setup the domain on Fly
  • Setup Resend to send emails (use the email in your .env/secret on fly)
  • Update the scripts/backup & scripts/restore-latest-backup script to use (any) one of your machine ids (line 5), app name, and Tigris bucket name (should be the same as app name)

Variables to replace

apple_domain = <your.apple.id> domain = billing-saas app_name = billing-saas app_display_name =billing-saas organization = brock-software primary_region = atl primary_fly_vm_id = <your_app_machine_id>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors