This tutorial will walk you through deploying your first Vapor app to Vapor Cloud.
Signup for Beta¶
If you haven't already, sign up for a beta account at https://dashboard.vapor.cloud/signup.
New beta spots are opened on a rolling basis, so be sure to check back regularly if you are unable to signup.
As of this writing, Vapor Cloud is still in very early beta. Use this service for testing only as you will likely encounter some bugs and incomplete features. Please report all bugs in Vapor's Slack or to email@example.com.
During the beta period, you will not be charged for any paid resources you use on Vapor Cloud. You may notice a negative account balance if you use paid resources, like databases. You can safely ignore any negative balances.
If you don't already have Vapor installed on your computer, follow the guide at https://docs.vapor.codes/2.0/getting-started/install-on-macos/. Or for Ubuntu: https://docs.vapor.codes/2.0/getting-started/install-on-ubuntu/.
Install Beta Toolbox¶
Vapor Cloud applications are deployed through the Vapor Toolbox.
There is a beta version of the toolbox available that includes the
cloud commands. You can install this version
of the toolbox through Homebrew.
brew install vapor-beta
You can also install through APT.
sudo apt-get install vapor-beta
If you have not already configured Vapor's Homebrew or APT sources on your computer, visit https://docs.vapor.codes/2.0/getting-started/toolbox/. This guide works for the beta version of the toolbox as well.
Verify that the beta toolbox is correctly installed by calling the help command.
vapor-beta cloud --help
Create an Organization¶
If you didn't already create an organization during the signup process, create one now.
You can do this through the toolbox
vapor-beta cloud create org or through the dashboard.
Create a Project¶
You can do this through the toolbox
vapor-beta cloud create proj or through the dashboard.
Projects help organize related applications. You can invite individual users to your projects and assign read, write, or admin permissions. You can even create teams of users and add those to your projects.
You cannot assign different permissions to each application, only to a project. So feel free to create as many projects as you want for your permissioning needs.
Now that we have created an Organization and Project, we can begin our first deployment.
To deploy your app, your code needs to be available through Git. The easiest way to do this is through GitHub.
The toolbox will automatically walk you through this process and the other required steps to deploy your first app.
Let's get started.
vapor-beta cloud deploy
Create Git Remote¶
The easiest way to host code for your deployed project is as a public repo on GitHub.
If you would like to use this method, respond
yes to the first prompt. GitHub will be opened automatically.
Once you have created your new repository (or using an existing) copy the SSH (not HTTP) url into the next prompt.
After the Git remote has been added, you can create your first application. Each application can have multiple services, such as hosting, databases, caches, and more.
Not every Vapor Cloud application needs to have hosting. For instance, you could create a Vapor Cloud application that just consists of a MySQL database for your own use.
However, in this tutorial, we will be creating an application with hosting.
Respond yes to the prompt to create an application. Give it a name, and a slug.
Application slugs will be used to access your app on Vapor Cloud. If you use the slug
foo, then your application would
be accessible at
If you create environments besides
dev, then you can access those separate environments using a
- suffix. For example,
As we mentioned in the previous section, we will be adding the hosting service to our application to host our Vapor app.
yes to the prompt to create hosting, and select the Git URL that we just added previously.
The hosting service can have unlimited environments. This is useful for creating environments like testing, staging, devlopment, and more.
For now, we will create our main
production environment. This environment is special because it is not followed by a suffix in the
To create this special environment, ensure the environment name is exactly
After you have named your environment, choose the branch it will deploy from. This is usually the
master branch for
During the beta account, all environments are limited to
Free size replicas. This size has a monthly request limit, but is free forever. Select the
Free size for this environment.
Add Database (Optional)¶
Next you will be asked if you'd like to add a database. If your application will need a database, you can do this now.
Otherwise, ignore the prompt. You can always add a database later using
vapor cloud create db.
If you do add a database, the environment variables to accesso the database will be exposed to your Vapor application's config.
See https://docs.vapor.cloud/database/mysql/ for more information about accessing these variables.
For high availability and throughput, Vapor Cloud allows you to deploy your application to multiple replicas. However,
for Free size replicas you are limited to
1 replicas. If you set the replica count to
0 your application will be taken offline. If you set it to
1 it will be online.
Set the replica count to
1 so that our application will be online when we deploy.
The Swift Package Manger 3.1 allows a few different ways to build your application.
Vapor Cloud simply runs
swift build on your application. Dependencies are not updated. This is the fastest method for subsequent deploys.
Vapor Cloud runs
swift package update before running
swift build. This option is slightly slower than incremental, but required if you have modified your
Vapor Cloud deletes all build metadata (such as the
.build folder) then runs
swift build on your application. This option takes a considerably longer amount of time than update or incremental, but can sometimes fix strange build issues.
These build types will be simplified in SPM 4.0 and this question will likely go away.
Verify that the information is correct and deploy your application! Once your app is deployed, you will get a URL to visit in your browser.
Congratulations on deploying your first app through Vapor Cloud.
Please let us know if you have any ideas or feature requests through https://ideas.vapor.cloud.
Also free free to chat with one of us through the chat feature (blue bubble in lower right corner) in https://dashboard.vapor.cloud.