You’ve gone to the Shopify dev docs, scaffolded an app using Remix and the Shopify CLI and got everything working on a local development server.
Time to deploy, perhaps because you are ready for production, or perhaps because you are building an app to be embedded in the Shopify admin or Shopify Point of Sale using App Bridge.
The instructions for Deploying to a hosting service include Render, Heroku, and Fly.io.
As of today, those Fly.io instructions are obsolete. The new instructions look like this:
Assuming you are using the Shopify CLI and the Remix template, give it a try. If you don’t have a ready shopify app, you can use the QRCode example that Remix provides:
git clone https://github.com/rubys/example-app--qr-code--remix qrcode
cd qrcode
shopify app config link
At this point, if you want to try out Sqlite, run fly launch
.
Or you can switch to PostgreSQL:
sed -i.bak 's/"file:dev.sqlite"/env("DATABASE_URL")/;s/sqlite/postgresql/' prisma/schema.prisma
rm -rf prisma/migrations
export DATABASE_URL=postgres://$USER@localhost/testdb
npm install
npx prisma migrate dev --name init
While the first line may look daunting, what it is doing is making the following change to your prisma/schema.prisma
file:
datasource db {
- provider = "sqlite"
- url = "file:dev.sqlite"
+ provider = "postgresql"
+ url = env("DATABASE_URL")
}
Once you have updated your schema configuration and generated your migrations, you are ready to run fly launch
.
Notes
- At this time, this is only for Shopify apps using the Remix template with the Shopify CLI.
- All machines will automatically be configured to stop when not in use, and restart on the next request; this is fine for development purposes, but for production you will need to adjust this to meet Shopify performance requirements. Depending on your requirements suspend, setting
min_machines_running
to 1, orauto_stop_machines
tooff
in the http service section of yourfly.toml
can be used make your app consistently respond quickly. - For Sqlite,
fly launch
will place the database on a volume, run migration in a startup script, and set up continuous streaming backups via LiteStream to Tigris S3 storage. This is for disaster recovery purposes. Should a machine and/or volume fail, delete both, runfly deploy
and you are back up and running - see the Prisma Sqlite demo for more details. - For PostgreSQL,
fly launch
will create a database for you, create two app machines for redundancy (enabling among other things, rolling deploys), and set things up where migrations are run on an ephemeral machine after the build and before deployments begin. For production, it is recommended that you add replicas. - I made a pull request with my modifications to the Dockerfile. I’m working with Shopify to update to their deployment documentation and/or link to a new page (or set of pages) on the fly.io site.