- Go to fly.io and click on Get Started.
- Download and install the Fly CLI
- From the command line, sign up for Fly:
flyctl auth signup
. You can sign up with an email address or with a GitHub account. - Fill in credit card information and click Subscribe.
-
Create an app using
flyctl launch
. You can choose your own app name or press enter to let Fly pick an app name. Choose a region for deployment (it should default to the closest one to you). Choose No for DB. Choose No to deploy now. -
To create a new app in the Partner Dashboard or to link the app to an existing app, run the following command using your preferred package manager:
Using yarn:
yarn run info --web-env
Using npm:
npm run info --web-env
Using pnpm:
pnpm run info --web-env
Take note of the
SCOPES
,SHOPIFY_API_KEY
and theSHOPIFY_API_SECRET
values, as you'll need them in the next steps. -
Make the following changes to the
fly.toml
file.-
In the
[env]
section, add the following environment variables (in a"
delimited string):Variable Description/value BACKEND_PORT
The port on which to run the app; set to the same value as the EXPOSE
line in theDockerfile
(Dockerfile
default value is8081
.HOST
Set this to the URL of the new app, which can be constructed by taking the app
variable at the very top of thefly.toml
file, prepending it withhttps://
and adding.fly.dev
to the end, e.g, ifapp
is"fancy-cloud-1234"
, thenHOST
should be set tohttps://fancy-cloud-1234.fly.dev
SCOPES
Can be obtained from the run info --web-env
command in the previous stepSHOPIFY_API_KEY
Can be obtained from the run info --web-env
command in the previous step -
In the
[[services]]
section, change the value ofinternal_port
to match theBACKEND_PORT
value. -
Example:
: : [env] BACKEND_PORT = "8081" HOST = "https://fancy-cloud-1234.fly.dev" SCOPES = "write_products" SHOPIFY_API_KEY = "ReplaceWithKEYFromEnvCommand" : : [[services]] internal_port = 8081 : :
-
-
Set the API secret environment variable for your app:
flyctl secrets set SHOPIFY_API_SECRET=ReplaceWithSECRETFromEnvCommand
-
Build and deploy the app - note that you'll need the
SHOPIFY_API_KEY
to pass to the commandflyctl deploy --build-arg SHOPIFY_API_KEY=ReplaceWithKEYFromEnvCommand --remote-only
-
Update main and callback URLs in Partner Dashboard to point to new app. The main app URL should point to
https://my-app-name.fly.dev
and the callback URL should be
https://my-app-name.fly.dev/api/auth/callback
-
Test the deployed app by browsing to
https://my-app-name.fly.dev/api/auth?shop=my-dev-shop-name.myshopify.com
-
After updating your code with new features and fixes, rebuild and redeploy using:
flyctl deploy --build-arg SHOPIFY_API_KEY=ReplaceWithKEYFromEnvCommand --remote-only
- Add a new region using
flyctl regions add CODE
, whereCODE
is the three-letter code for the region. To obtain a list of regions and code, runflyctl platform regions
. - Scale to two instances -
flyctl scale count 2