Sunday, March 13, 2022

Fly

I've been really happy with remix.run after some testing this week.

I deployed this site to fly.io and wanted to go through the steps of how I achieved this.

  1. Run the remix start command
npx create-remix@latest
  1. Set up Prisma, you can follow this guide but the commands are
npm install --save-dev prisma
npm install @prisma/client
# we want to use SQLite, its fast and simple
npx prisma init --datasource-provider sqlite
  1. Add some models to the schema.prisma file
  2. Run this command to create the database
# should create a dev.db in the prisma directory
npx prisma db push
  1. Add the db files to .gitignore
  2. Install the fly command line tools
brew install superfly/tap/flyctl
  1. Create a fly account
flyctl auth signup
  1. Launch the app
# make sure you don't deploy the app or add a PostgreSQL database
fly launch
  1. Check the Dockfile and that secrets are all set
  2. Ensure that all migrations have been run
npx prisma migrate dev
  1. Deploy the app
# can run fly logs to see how build is going
fly deploy
  1. If you change the structure of your database you'll need to run
npx prisma migrate dev --name <name-of-migration>

as this ensures that the Prisma Client is updated.