Deploy an app to Fly.io
In this tutorial, you'll learn how to apply the instructions to deploy an app into a Fly.io container.
Requirements
Anchor link to section titled "Requirements"You've created an app using Shopify CLI, or you've migrated your app to work with Shopify CLI.
You have a Fly.io account and can create apps on it.
Step 1: Create an app configuration file
Anchor link to section titled "Step 1: Create an app configuration file"Create or link your app to an app.toml
file. We recommend that developers have one configuration for development, and a separate one for production. That way, you can continue to develop your app after deploying it, without affecting your production environment.
Either create a new configuration, or use an existing one:
Get the necessary environment variables to deploy your app:
Note down the
SHOPIFY_API_KEY
,SHOPIFY_API_SECRET
, andSCOPES
values. You'll need to set them as environment variables before you can run your deployed app.
Step 2: Create Fly app
Anchor link to section titled "Step 2: Create Fly app"Create a new Fly app using the flyctl
tool.
- Install
flyctl
and sign up for Fly.io. For detailed steps, refer to the Fly.io docs. Run the following command to create a new app in Fly.io and create a
fly.toml
file:
This command creates an app container, but won't deploy it. You can deploy after you finish setting up the environment.
Step 3: Configure your app
Anchor link to section titled "Step 3: Configure your app"Configure your Fly.io app to run your app code and communicate with Shopify.
Prepare database
Anchor link to section titled "Prepare database"Create a container running your preferred database, then make sure your Prisma schema file points to it. For databases such as PostgreSQL or MySQL, you can use the DATABASE_URL
environment variable in your schema to point to your container in different environments.
Refer to these important considerations for setting up your database.
Set environment secrets
Anchor link to section titled "Set environment secrets"In a terminal, set the API secret for your app, using the SHOPIFY_API_SECRET
from the shopify app env show
command you ran before:
Step 4: Deploy your configuration
Anchor link to section titled "Step 4: Deploy your configuration"Before running the app on your hosting provider, you'll need to update your Shopify settings by deploying your TOML file using Shopify CLI.
In the
shopify.app.*.toml
file for your deployment environment, setapplication_url
to the same as theSHOPIFY_APP_URL
environment variable:Deploy your configuration to apply the changes to Shopify:
Step 5: Deploy your Fly.io app
Anchor link to section titled "Step 5: Deploy your Fly.io app"Your app is ready to deploy now. You can do that following these steps:
Deploy the app to Fly.io. You can do that using the
deploy
command:Visit your Fly.io dashboard, and check your logs to verify that the app started as expected.
Step 6: Test your deployed app
Anchor link to section titled "Step 6: Test your deployed app"After you update your app URLs in the Partner Dashboard, you can test your app in a development store to make sure that it's configured correctly.
- In the Partner Dashboard, go to your app's Overview page.
- In the Test your app section, click Select store and choose a store to test the app.
Re-deploying your app
Anchor link to section titled "Re-deploying your app"As you continue developing your app, you can re-deploy it with the following steps:
Select your production app with Shopify CLI:
Deploy your app configuration and extensions, if you made any changes:
Trigger a new deploy in Fly.io: