Deploying with the Wasp CLI
Wasp CLI can deploy your full-stack application with only a single command. The command automates the manual deployment process and is the recommended way of deploying Wasp apps.
Supported Providersβ
Wasp supports automated deployment to the following providers:
Fly.ioβ
Prerequisitesβ
Fly provides free allowances for up to 3 VMs (so deploying a Wasp app to a new account is free), but all plans require you to add your credit card information before you can proceed. If you don't, the deployment will fail.
You can add the required credit card information on the account's billing page.
You will need the flyctl
CLI installed on your machine before you can deploy to Fly.io.
Deployingβ
Using the Wasp CLI, you can easily deploy a new app to Fly.io with just a single command:
wasp deploy fly launch my-wasp-app mia
Please do not CTRL-C or exit your terminal while the commands are running.
Under the covers, this runs the equivalent of the following commands:
wasp deploy fly setup my-wasp-app mia
wasp deploy fly create-db mia
wasp deploy fly deploy
The commands above use the app basename my-wasp-app
and deploy it to the Miami, Florida (US) region (called mia
). Read more about Fly.io regions here.
Your app name must be unique across all of Fly or deployment will fail.
The basename is used to create all three app tiers, resulting in three separate apps in your Fly dashboard:
my-wasp-app-client
my-wasp-app-server
my-wasp-app-db
You'll notice that Wasp creates two new files in your project root directory:
fly-server.toml
fly-client.toml
You should include these files in your version control so that you can deploy your app with a single command in the future.
Using a Custom Domain For Your Appβ
Setting up a custom domain is a three-step process:
- You need to add your domain to your Fly client app. You can do this by running:
wasp deploy fly cmd --context client certs create mycoolapp.com
Make sure to replace mycoolapp.com
with your domain in all of the commands mentioned in this section.
This command will output the instructions to add the DNS records to your domain. It will look something like this:
You can direct traffic to mycoolapp.com by:
1: Adding an A record to your DNS service which reads
A @ 66.241.1XX.154
You can validate your ownership of mycoolapp.com by:
2: Adding an AAAA record to your DNS service which reads:
AAAA @ 2a09:82XX:1::1:ff40
You need to add the DNS records for your domain:
This will depend on your domain provider, but it should be a matter of adding an A record for
@
and an AAAA record for@
with the values provided by the previous command.You need to set your domain as the
WASP_WEB_CLIENT_URL
environment variable for your server app:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=https://mycoolapp.com
We need to do this to keep our CORS configuration up to date.
That's it, your app should be available at https://mycoolapp.com
! π
API Referenceβ
launch
β
launch
is a convenience command that runs setup
, create-db
, and deploy
in sequence.
wasp deploy fly launch <app-name> <region>
It accepts the following arguments:
<app-name>
- the name of your app required<region>
- the region where your app will be deployed requiredRead how to find the available regions here.
It gives you the same result as running the following commands:
wasp deploy fly setup <app-name> <region>
wasp deploy fly create-db <region>
wasp deploy fly deploy
Environment Variablesβ
If you are deploying an app that requires any other environment variables (like social auth secrets), you can set them with the --server-secret
option:
wasp deploy fly launch my-wasp-app mia --server-secret GOOGLE_CLIENT_ID=<...> --server-secret GOOGLE_CLIENT_SECRET=<...>
setup
β
setup
will create your client and server apps on Fly, and add some secrets, but does not deploy them.
wasp deploy fly setup <app-name> <region>
It accepts the following arguments:
<app-name>
- the name of your app required<region>
- the region where your app will be deployed requiredRead how to find the available regions here.
After running setup
, Wasp creates two new files in your project root directory: fly-server.toml
and fly-client.toml
.
You should include these files in your version control.
You can edit the fly-server.toml
and fly-client.toml
files to further configure your Fly deployments. Wasp will use the TOML files when you run deploy
.
If you want to maintain multiple apps, you can add the --fly-toml-dir <abs-path>
option to point to different directories, like "dev" or "staging".
You should only run setup
once per app. If you run it multiple times, it will create unnecessary apps on Fly.
create-db
β
create-db
will create a new database for your app.
wasp deploy fly create-db <region>
It accepts the following arguments:
<region>
- the region where your app will be deployed requiredRead how to find the available regions here.
You should only run create-db
once per app. If you run it multiple times, it will create multiple databases, but your app needs only one.
deploy
β
wasp deploy fly deploy
deploy
pushes your client and server live.
Run this command whenever you want to update your deployed app with the latest changes:
wasp deploy fly deploy
cmd
β
If want to run arbitrary Fly commands (e.g. flyctl secrets list
for your server app), here's how to do it:
wasp deploy fly cmd secrets list --context server
Fly.io Regionsβ
Fly.io runs applications physically close to users: in datacenters around the world, on servers we run ourselves. You can currently deploy your apps in 34 regions, connected to a global Anycast network that makes sure your users hit our nearest server, whether theyβre in Tokyo, SΓ£o Paolo, or Frankfurt.
Read more on Fly regions here.
You can find the list of all available Fly regions by running:
flyctl platform regions
Environment Variablesβ
If you are deploying an app that requires any other environment variables (like social auth secrets), you can set them with the secrets set
command:
wasp deploy fly cmd secrets set GOOGLE_CLIENT_ID=<...> GOOGLE_CLIENT_SECRET=<...> --context=server
Mutliple Fly Organizationsβ
If you have multiple organizations, you can specify a --org
option. For example:
wasp deploy fly launch my-wasp-app mia --org hive
Building Locallyβ
Fly.io offers support for both locally built Docker containers and remotely built ones. However, for simplicity and reproducibility, the CLI defaults to the use of a remote Fly.io builder.
If you want to build locally, supply the --build-locally
option to wasp deploy fly launch
or wasp deploy fly deploy
.