Bryan

Bryan

twitter
medium

Deploy Windmill using Fly.io

Windmill is an open-source, self-deployable workflow engine (or even a low-code platform) that can be accessed at https://www.windmill.dev/docs/compared_to to see its official comparison with services like Zapier.

This article will show you how to deploy it to Fly.io.

Overview#

This article introduces two ways to deploy Windmill, which I call minimal and full modes.

In the minimal mode, all Windmill components run in a single app, which is the simplest and most economical solution, but not flexible enough (for example, because the server and worker run in the same container, it is difficult to scale horizontally);
In the full mode, Windmill components are split into two different apps, one running the server and the other running the worker. Compared to the minimal solution, this is more complex but allows you to have more flexible control over distributed workers.

Clone the repository windmill-on-fly and then continue with the following steps.

LSP Component#

Both minimal and full modes require LSP to be installed in advance.

LSP provides code completion functionality on the Windmill frontend page and needs to be deployed independently.

Launch & Deploy#

If you want to modify the region, please modify the primary_region field in the fly.toml file (default is sea). If you modify the region, it is recommended to keep the regions of all apps consistent for the best experience.

Go to the lsp directory and execute fly launch to start the project; when prompted with Would you like to copy its configuration to the new app? (y/N), choose Y and give the app a name later.

If my-windmill-lsp appears later in this article, replace it with the app name you set here.

In the following prompts, do not create Postgresql and Redis (choose N for all related prompts).

When asked Would you like to deploy now? (y/N), choose Y to deploy.

Allocate IP#

After deployment, execute fly ips allocate-v6 --private to allocate a Private IP for the service (you can also delete all Public IPs at the same time).

Scale#

LSP has higher performance requirements. Based on my actual experience, it is recommended to allocate at least 4GB of memory to use it normally. You can execute fly scale vm performance-2x to scale.

Considering the price factor, you can enable auto_start_machines=true and auto_stop_machines=true in fly.toml to save costs.

Minimal Mode Deployment#

If you choose the Full mode, please skip this step.

All the following operations are performed in the minimal directory.

Launch#

Execute fly launch to start the project; when prompted with Would you like to copy its configuration to the new app? (y/N), choose Y and give the app a name later.

If my-windmill appears later in this article, replace it with the app name you set here.

In the following prompts, do not create Postgresql and Redis (choose N for all related prompts).

When asked Would you like to deploy now? (y/N), choose N to skip the deployment.

Configure the Database#

Please follow the Fly Postgres Tutorial to create a database cluster.

Replace my-pg in the following command with the name of your database cluster.

Execute fly pg attach my-pg --superuser to create the database and user.

Configure LSP#

Edit the Caddyfile and replace xxx-windmill-lsp with the name of your own windmill-lsp service.

(Optional) Bind Custom Domain#

If you do not have or do not want to bind a custom domain, please skip this step.

Execute fly certs add YOUR_DOMAIN to configure a custom domain (replace YOUR_DOMAIN with your domain) and configure the corresponding CNAME record as required.

Configure Environment Variables#

Open the fly.toml file and modify env.BASE_URL to your external access domain - if you are not using a custom domain, enter https://my-windmill.fly.dev here, otherwise enter https://YOUR_DOMAIN.

If you want to modify the number of workers, you can modify the value of the env.NUM_WORKERS variable.

Deploy#

Enter fly deploy to deploy (the deployment process will automatically build the required images and create the necessary volumes). Wait for the deployment to succeed and access your instance to test logging in using the account admin@windmill.dev with the password changeme.

Full Mode Deployment#

If you choose the Minimal mode, please skip this step.

The full directory includes two directories - server and worker, which store the configurations of the Server and Worker components.

Server - Launch#

Go to the full/server directory and execute fly launch to start the project; when prompted with Would you like to copy its configuration to the new app? (y/N), choose Y and give the app a name later.

If my-windmill-server appears later in this article, replace it with the app name you set here.

In the following prompts, do not create Postgresql and Redis (choose N for all related prompts).

When asked Would you like to deploy now? (y/N), choose N to skip the deployment.

Server - Configure the Database#

Please follow the Fly Postgres Tutorial to create a database cluster.

Replace my-pg in the following command with the name of your database cluster. Use windmill for both the database name and database user, or modify them to your desired names.

Go to the full/server directory and execute fly pg attach my-pg --superuser --database-name windmill --database-user windmill to create the database and user.

Record the DATABASE_URL printed when executing the above command for later use.

Server - Configure LSP#

Go to the full/server directory and edit the Caddyfile, replacing xxx-windmill-lsp with the name of your own windmill-lsp service.

(Optional) Server - Bind Custom Domain#

If you do not have or do not want to bind a custom domain, please skip this step.

Go to the full/server directory and execute fly certs add YOUR_DOMAIN to configure a custom domain (replace YOUR_DOMAIN with your domain) and configure the corresponding CNAME record as required.

Server - Configure Environment Variables#

Go to the full/server directory and open the fly.toml file, modify env.BASE_URL to your external access domain - if you are not using a custom domain, enter https://my-windmill-server.fly.dev here, otherwise enter https://YOUR_DOMAIN.

Server - Deploy#

Go to the full/server directory and enter fly deploy to deploy (the deployment process will automatically build the required images and create the necessary volumes).

By default, a new fly app without volumes will deploy two instances. Multiple instances for the server are usually not necessary, so you can execute fly scale count 1 to delete the extra instances.

Wait for the deployment to succeed and access your instance to test logging in using the account admin@windmill.dev with the password changeme.

Worker - Launch#

Go to the full/worker directory and execute fly launch to start the project; when prompted with Would you like to copy its configuration to the new app? (y/N), choose Y and give the app a name later.

If my-windmill-worker appears later in this article, replace it with the app name you set here.

In the following prompts, do not create Postgresql and Redis (choose N for all related prompts).

When asked Would you like to deploy now? (y/N), choose N to skip the deployment.

Worker - Configure the Database#

Go to the full/worker directory and execute fly secrets set 'DATABASE_URL=xxx' --stage to configure the credentials for connecting to the database. (Replace xxx with the content of the DATABASE_URL printed in the previous steps)

Worker - Configure Environment Variables#

Go to the full/worker directory and open the fly.toml file, modify env.BASE_URL to the external access domain of your windmill-server - if you are not using a custom domain, enter https://my-windmill-server.fly.dev here, otherwise enter https://YOUR_DOMAIN.

If you want to modify the number of workers, you can modify the value of the env.NUM_WORKERS variable.

Worker - Deploy#

Go to the full/worker directory and enter fly deploy to deploy.

Access the /workers route of your instance (e.g., https://my-windmill-server.fly.dev/workers) to see if your workers are displayed.

Frequently Asked Questions#

Upgrade (or specify version number)#

All current version numbers use latest, which may not be suitable for production (because each redeployment will upgrade to the latest version).

The version numbers are in the following files:

  • lsp/fly.toml
  • minimal/Dockerfile
  • full/server/Dockerfile
  • full/worker/fly.toml

You can replace latest in "ghcr.io/windmill-labs/windmill:latest" in these files with the version number you want, such as 1.133.

The only thing to note is to always keep all version numbers consistent, otherwise unknown issues may occur.

Upgrade: After modifying the version number, re-execute fly deploy in the respective directories.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.