2. Deploy your app to the cloud

In step 1 you created your first Encore app and ran it locally. Now is the time to deploy it to production, using the Encore Platform.

Encore automatically creates a production environment named prod and deploys to it automatically when you push.

Commit and push your change

Now it's time to push our freshly coded API and see it deployed!

Go back to your terminal, and commit the hello service:

$ git add hello
$ git commit -m 'Add hello service'
$ git push

Git will output a bunch of stuff, but towards the end you should see something like this:

remote: refs/heads/main: triggered build yhgznbufao
To encore://hello-world-4x3b
   84a7586..17f9750  main -> main

That means a build has been triggered, and if that succeeds Encore will deploy your change.

Head over to app.encore.dev again, open your app, and open the Builds page and you should see the build you just triggered.

Once it completes successfully, click the Deploy menu item under the prod environment in the menu on the left. Here you will see the deploy once the has build completed successfully.

Once the deploy completes, your app is up and running in production!

Call your API

To verify that it's running, let's call our API. There are two ways to do this: through the Encore Platform, and directly from the terminal. Let's do both!

On app.encore.dev with your app open, click the API menu item in the menu on the left. You should see the API Documentation for your app, with the hello service and its World endpoint.

Next to the World endpoint, click the Call button on the right-hand side. Then, click Send to make an API call. You should see the response: {"Message": "Hello, World!"}.

Now, open your terminal and run (replace hello-world-4x3b with your own App ID):

$ curl https://hello-world-4x3b.encoreapi.com/prod/hello.World
{"Message": "Hello, world!"}

If you see this, you've successfully deployed and made an API call to your very first Encore app in production. Nicely done!

Move on to the next step of the tutorial to add a SQL database to your service.