Deploying ActivePieces on Fly.io?

I’m attempting (and failing) to run Activepieces in fly.io, and would be grateful if anyone has suggestions. (I saw that there’s a one-click deployment for Railway, so I’m assuming it must be possible on Fly as well.

I’m running into this issue on deploy:

[info]Migration "PieceMetadata1685537054805" failed, error: current database's encoding is not supported with this provider

Here are the steps I took:

  1. fly pg create and copy the postgres connection string.

  2. launch an app for ActivePieces with the following fly.toml

[build]
image = 'activepieces/activepieces:latest'

[env]
AP_DB_TYPE = 'POSTGRES'
AP_ENGINE_EXECUTABLE_PATH = 'dist/packages/engine/main.js'
AP_ENVIRONMENT = 'prod'
AP_EXECUTION_MODE = 'UNSANDBOXED'
AP_FRONTEND_URL = 'http://localhost:8080'
AP_QUEUE_MODE = 'MEMORY'
AP_SANDBOX_RUN_TIME_SECONDS = '600'
AP_TELEMETRY_ENABLED = 'false'
AP_TRIGGER_DEFAULT_POLL_INTERVAL = '5'
AP_WEBHOOK_TIMEOUT_SECONDS = '30'

[http_service]
internal_port = 4200
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 1

[http_service.concurrency]
type = 'requests'
hard_limit = 250
soft_limit = 200

[[vm]]
memory = '512mb'
cpu_kind = 'shared'
cpus = 1
  1. setting some secrets:
fly secrets set \
  AP_API_KEY=$(openssl rand -hex 64) \
  AP_JWT_SECRET=$(openssl rand -hex 32) \
  ENCRYPTION_KEY=$(openssl rand -hex 16) \
  AP_POSTGRES_URL=<postgres connection string>
  1. deploy

The deployment starts, and the database begins to be set up (15-20 lines of successful database transactions in the log), and then the error I mentioned at the beginning of this post appears, and deployment can’t continue. I’m unsure of how to proceed.

@abuaboud can you please help with this?

1 Like

The Postgres database that Fly sets up has SQL_ASCII encoding and I believe ActivePieces requires UTF8. I successfully followed these instructions to alter the database to UTF8, but afterwards, the console returned the same error. I think it might have something to do with ICU, but I’m out of my depth.

I was informed by Fly.io support that their postgres-flex image has been upgraded to Postgres 16, and with that change, the default encoding switched from UTF8 to SQL_ASCII.

I don’t know whether that encoding change is specific to Fly’s image, but given these lines from the Postgres 16 release notes

  • Determine the default encoding from the locale when using ICU (Jeff Davis)

    Previously the default was always UTF-8.

…I’m guessing that this might apply more generally?

In any case—for now, for those wishing to run ActivePieces on Fly, provision the Postgres app with fly postgres create --image-ref flyio/postgres-flex:15, which will use Fly’s Postgres 15 postgres-flex image, whose default encoding is UTF8.

Hi @paulrudy

This is quite interesting topic, I do love fly.io :smiley:

Did it work after you change the encoding?

1 Like

Yes, it did work with the Postgres 15 image.

Today I got a reply from Fly.io that they’ve made a change so that now new Postgres apps will deploy with the UTF8 encoding and the latest Postgres (16 as of now):

Good news, it turns out this was a quick fix! Newly provisioned postgres-flex clusters are back to using UTF-8 encoding as the default. Existing clusters that were provisioned with the SQL_ASCII encoding will stay with that, but new clusters will use UTF-8 again.

Thanks for bringing this to our attention.

I can confirm that I’m now running on Postgres 16, and there’s no longer any need to specify a specific Postgres image when deploying ActivePieces on Fly.

Awesome, Super happy that it works!

I am thinking if you can open pull request or tell us what’s needed so we can document fly.io as provider here
Overview - Activepieces

Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.