Docs

Documentation versions (currently viewingVaadin 24)

Deploy to Production

Learn how to deploy your Vaadin application to the cloud

You are now ready to deploy your application. In this tutorial, you will be deploying to Fly.io, as they have a cheap hobby plan that includes a free trial. However, even if you are only going to use the free trial, you are required to enter a valid credit card number.

You need to have Docker installed and running on your machine before you can proceed with this step.

Prepare Fly.io

Before you can deploy to Fly.io, you need to install a command-line utility and create an account. Follow the instructions here.

Create a Docker image

You are now going to turn your application into a Docker image. The easiest way to do this is to use the Spring Boot maven plugin, which in turn uses buildpacks to make an image from your application.

Run this command in the root directory of your project to start the build:

./mvnw clean spring-boot:build-image -Pproduction

The build will take some time to complete, especially the first time you run it. Once it has completed, verify that the image has been created by running this command:

docker image ls -a

You should see a line for the image you just created: unified-chat-tutorial-flow 1.0-SNAPSHOT 438ec79fe5a3 (the hash may be different on your machine).

Next, try out the new Docker image by running this command:

docker run -p8080:8080 unified-chat-tutorial:1.0-SNAPSHOT

You should now be able to access the application at http://localhost:8080. Once you have verified that the application is running, stop the container by pressing Ctrl-C.

Deploy to Fly.io

You are now ready to deploy the application to Fly.io. Start the deployment by running this command:

fly launch --image unified-chat-tutorial:1.0-SNAPSHOT --local-only

The tool will suggest settings for you and ask if you want to make any changes to them. Select the default answer (no) by pressing Enter.

It will then ask if you want to create a .dockerignore file. Again, select the default answer (no) by pressing Enter. The deployment process should now begin.

Once the deployment is finished, the tool will give you the URL at which the application can be visited. Try it out!

Remember to delete the application when you no longer need it to avoid unnecessary charges on your credit card:

fly apps destroy unified-chat-tutorial

You can also delete the app using the Fly.io dashboard.