Skip to content

Deployment

A production deployment of FlowPayra Lite is the single binary flowpayra-lite plus PostgreSQL 15 or later. The checkout and console front ends, the contract code and the database migrations are compiled into the binary, so building the image needs neither Node nor Foundry.

  1. Build the image; generate the master key and the quote signer key.
  2. Fill in deploy/.env and the configuration file, and start the services.
  3. Put an HTTPS reverse proxy in front and set public_url.
  4. Create the first admin and sign in to the console.
  5. Per chain, deploy the merchant contracts and list tokens; configure the hot wallet if needed.
  6. Set up backups, health checks and monitoring.
Terminal window
docker build -t flowpayra-lite . # multi-stage build; the runtime image is based on debian:bookworm-slim
docker run --rm flowpayra-lite keygen # generate the master key (32 bytes, hex)
  • The container runs as the non-root user flowpay (uid 10001) and listens on 0.0.0.0:8080; its HEALTHCHECK probes /healthz.
  • The configuration file is /etc/flowpay/config.toml (named by the FLOWPAY_CONFIG environment variable; the file may be absent).
  • Any setting can be overridden by a FLOWPAY_* environment variable, nested keys joined with __, for example FLOWPAY_DATABASE__URL.
  • Keystore files are mounted read-only at /etc/flowpay/keys; their passwords are read from environment variables.
  • The default command is serve, which runs every role.

The repository’s docker-compose.yml contains the app and postgres:16: the database uses the pgdata volume, is reachable only on the compose network, and must be healthy before the app starts. deploy/config.docker.toml is mounted as /etc/flowpay/config.toml; deploy/.env and the files in deploy/keys/ stay out of version control.

Terminal window
cp deploy/.env.example deploy/.env # fill in the variables below
cast wallet new deploy/keys quote-signer.json # new quote signer keystore (or: cast wallet import … -k deploy/keys -i for an existing key)
docker compose --env-file deploy/.env up -d --build

Variables in deploy/.env:

Variable Description
FLOWPAY_SECRETS__MASTER_KEY The master key; required
FLOWPAY_SIGNER_PASSWORD Password of deploy/keys/quote-signer.json
FLOWPAY_RELAYER_PASSWORD Password of deploy/keys/hot-wallet.json, when the hot wallet is enabled
FLOWPAY_PUBLIC_URL The HTTPS address payers and admins reach
FLOWPAY_HTTP_PORT Host port the app is published on; default 8080
FLOWPAY_KEYS_DIR Directory holding the keystores; default ./deploy/keys
POSTGRES_PASSWORD Password of the bundled database
FLOWPAY_IMAGE Set it to use a registry image, and start with --no-build

Every option is listed in config.example.toml in the repository. The following matter in production.

listen = "0.0.0.0:8080"
public_url = "https://pay.example.com"
# trusted_proxies = ["127.0.0.1"]
  • public_url is the address payers reach this deployment at. Checkout links are built from it, and it is the console’s passkey (WebAuthn) site. Production needs an HTTPS domain.
  • trusted_proxies lists the reverse proxies in front of the server, as exact IP addresses. Their X-Forwarded-For gives the client IP used for the help form’s rate limits and the audit log; leave it empty when clients connect directly.
[admin]
# listen = "10.0.0.5:8081"
# public_url = "https://admin.example.internal"
  • By default the console shares the public listener. With listen set, the console (/admin and /admin/api) is served only on that address, for example an internal interface or a separate port; the public listener answers 404 for /admin. The console listener serves only the console and /healthz.
  • Set admin.public_url when admins open the console at an address other than public_url. It is the console’s passkey site and the link in admin notification emails.
[database]
url = "postgres://flowpay:[email protected]:5432/flowpay"
max_connections = 10
migrate_on_start = true

max_connections is the pool shared by API requests and background queries. Background roles elect a leader with PostgreSQL advisory locks, and each lock sits on a dedicated connection outside the pool: up to 7 per instance, plus 1 per indexed chain. Size PostgreSQL’s own max_connections for at least instances × (pool size + 7 + chains), with headroom. For example, 2 instances and 3 chains: 2 × (10 + 7 + 3) = 40.

[secrets]
# master_key = ""
# previous_master_keys = []
  • The master key is a 32-byte hex key that encrypts every sensitive value in the database: RPC URLs, webhook secrets, email addresses, the stored quote signer keys and credentials. Generate it with flowpayra-lite secrets keygen (or flowpayra-lite keygen, which prints the key only).
  • It stays in the configuration or the environment, never in the database. Prefer the environment variable FLOWPAY_SECRETS__MASTER_KEY.
  • Without the master key that data cannot be decrypted. Keep it separately from database backups: pipe it from the configuration straight into a password manager or an encrypted file, never showing it in a terminal, then check the copy with flowpayra-lite secrets check-backup (reads the copy from standard input, never prints the key), which opens the encrypted data in the database with it.
  • previous_master_keys is used only while rotating the master key, for decryption. Rotation is done from the console’s Master key page.

Console “Master key” page: the current fingerprint and the encrypted data by location

[quote_signer]
keystore = "/etc/flowpay/keys/quote-signer.json"
password_env = "FLOWPAY_SIGNER_PASSWORD"
  • Production uses an Ethereum JSON keystore, with its password in the named environment variable.
  • The configured key joins the keyring on the first start (stored in the database, encrypted under the master key) as the active key. Afterwards, take an offline backup with flowpayra-lite signer export and keep the backup file and its password apart.
  • The quote signer key’s address is embedded in the merchant contracts. Replacing the key means deploying new merchant contracts for the new key, from the console’s Quote signer keys page or with flowpayra-lite signer ….
  • Solana chains use a separate ed25519 quote signer key, generated on the Quote signer keys page or with flowpayra-lite signer generate --scheme ed25519.

The quote signer key can also live in AWS KMS or Google Cloud KMS; this is off by default. Enable it and add a connection in the signing backends / KMS section of the console’s Quote signer keys page, or with the flowpayra-lite kms … commands.

  • AWS KMS: key spec ECC_SECG_P256K1; credentials are an access key or the server environment (environment variables, an ECS / EKS task role, an EC2 instance role).
  • Google Cloud KMS: algorithm EC_SIGN_SECP256K1_SHA256; credentials are a service account key file or the metadata server.
  • Keys in a KMS cannot be exported; their backup is the cloud provider’s responsibility. KMS supports secp256k1 keys only (EVM and TRON chains); the hot wallet remains a local key.
[relayer]
# keystore = "/etc/flowpay/keys/hot-wallet.json"
# password_env = "FLOWPAY_RELAYER_PASSWORD"
replace_after_secs = 90
min_balance_wei = "0"

The hot wallet sponsors gas and sends subscription charges: configure it, and fund it with a small amount of native coin, when using gas sponsorship or subscriptions. It must differ from the quote signer key and should hold only a small balance. Solana chains have a separate solana_keystore option. See Gas and hot wallets.

Setting Description
[orders] default_ttl_secs Default order lifetime; 1800 seconds
[orders] quote_ttl_secs Quote validity; 600 seconds
[metrics] token Enables /metrics when set (see below)
[mail] dns_server DNS server for the console’s sender-domain checks (SPF, DKIM, DMARC)
[log] json true writes one JSON object per line, for log collectors
[diag] enabled The wallet diagnostic page /diag/; keep false in production

The WalletConnect projectId is not in the configuration file; it is entered in the console, see Wallet support.

The server speaks plain HTTP. Put a reverse proxy (Caddy, nginx or similar) in front to terminate TLS and forward requests to it.

Item Requirement
public_url The HTTPS address of the checkout and the API (FLOWPAY_PUBLIC_URL with docker compose). The server builds links from it; it does not read the Host or X-Forwarded-Proto headers
trusted_proxies The proxy’s IP address as the server sees it. Entries are exact IP addresses, not ranges. Only connections from these addresses have their X-Forwarded-For header read, so the proxy must set that header
Request size Most requests are limited to 64 KB by the server. The payment help form accepts up to about 16 MB (three screenshots of 5 MB each), and a risk list import in the console up to 24 MB. Caddy sets no limit of its own; with nginx, raise client_max_body_size (1 MB by default) accordingly
Protocol Ordinary HTTP requests and responses only; the server has no WebSocket endpoints. A request that takes longer than 30 seconds is ended by the server with 408
Page rewriting The content security policy of the HTML pages (checkout, console, payment help and so on) allows scripts from the site itself only (the payment help page also allows the human verification service that is turned on), and the pages are sent with Cache-Control: no-transform. Proxies and CDNs that honour the header, such as Cloudflare, therefore leave the pages unchanged (no injected analytics beacon, Rocket Loader or email obfuscation). The proxy should not remove the header or inject scripts into the pages; the browser would block such scripts

With docker compose the proxy on the host reaches the container through the Docker network, so the address the server sees is that network’s gateway, not 127.0.0.1 (the commented example in deploy/config.docker.toml is 172.18.0.1; docker network inspect shows the actual gateway). Set FLOWPAY_HTTP_PORT to change the host port the public listener is published on.

By default the console shares the public listener (port 8080): one hostname serves the checkout, the API and the console, which is at https://pay.example.com/admin/.

pay.example.com {
reverse_proxy 127.0.0.1:8080
}

To serve the checkout and API at pay.example.com and the console at admin.example.com, give the console its own listener. There is no default console port; 8081 is used here.

listen = "0.0.0.0:8080"
public_url = "https://pay.example.com"
trusted_proxies = ["127.0.0.1"] # with docker compose: the Docker network's gateway
[admin]
listen = "0.0.0.0:8081"
public_url = "https://admin.example.com"

With docker compose, make these changes in deploy/config.docker.toml (public_url comes from FLOWPAY_PUBLIC_URL), and publish the console port by adding it to the ports of the app service in docker-compose.yml:

ports:
- "${FLOWPAY_HTTP_PORT:-8080}:8080"
- "127.0.0.1:8081:8081"

The Caddy configuration then has one site per listener:

pay.example.com {
reverse_proxy 127.0.0.1:8080
}
admin.example.com {
reverse_proxy 127.0.0.1:8081
}
  • Caddy obtains the certificates and sets X-Forwarded-For itself. With nginx, add proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; to each location.
  • The console is at https://admin.example.com/admin/. The console listener serves only /admin, /admin/api and /healthz; the public listener answers 404 for /admin.
  • /readyz and /metrics are on the public listener.
  • The console listener can instead be bound to an internal address (for example listen = "10.0.0.5:8081") and reached without a public hostname; admin.public_url is then the internal address admins open.
Terminal window
docker compose --env-file deploy/.env exec -e FLOWPAY_ADMIN_PASSWORD='…' app flowpayra-lite admin create --username alice

The password needs at least 12 characters. On the first sign-in the admin sets up a second factor (a passkey, a security key or Google Authenticator), and the system generates 10 single-use recovery codes. Further members are added on the console’s Team page.

An admin who has lost every factor can be reset on the server:

Terminal window
flowpayra-lite admin reset --username alice --new-password

The command clears all of the account’s factors; with --new-password it resets the password too. See Admins and passkeys.

  1. Each chain: add the chain in the console’s Chains & tokens page, deploy and verify the merchant contracts through the Contracts checklist, then enable the chain. The command-line equivalent takes two steps: flowpayra-lite deploy all --rpc <RPC> --signer <quote signer address> (the paying key comes from the environment variable FLOWPAY_DEPLOYER_KEY) deploys the contracts, sending transactions only and writing nothing to the database; then flowpayra-lite signer verify --address <quote signer address> --chain <chain id> verifies and records them. Give --chain for a chain that is not enabled yet: without it, signer verify covers only enabled chains.
  2. Tokens: list tokens on each chain; their capabilities are probed on listing.
  3. RPC endpoints: at least 2 endpoints per chain are recommended, one of them wss, for lower booking latency.
  4. Hot wallet: configure and fund it for gas sponsorship or subscriptions.

These steps are covered in Chains and contracts.

serve runs every role by default. Multi-instance deployments can split them with --role, for example serve --role api and serve --role indexer,notifier,expirer,relayer.

Role Responsibility
api The business API, the checkout and the console. Stateless; scales horizontally
indexer One per chain: reads the merchant contracts’ events, books payments once confirmed, handles reorganisations
notifier Delivers webhooks, emails and alerts
expirer Scheduled work such as order expiry, refund re-checks and list imports
relayer Sends sponsored transactions from the hot wallet; the keeper (subscription charges and on-chain cancellations) runs with this role

Background roles elect a leader through PostgreSQL advisory locks, so only one instance does the work at a time; when the leader is lost, another instance takes over within about 10 seconds.

Endpoint Purpose
/healthz Process liveness only; use it for container liveness probes
/readyz Checks the database and returns 503 when it is unavailable; also reports the RPC status of each enabled chain, WalletConnect and the quote signer key. A problem in those reports as degraded without a 503, which suits load balancers
/metrics Prometheus metrics: order states, webhook and email queues, chain heights and indexing lag, RPC endpoint health and latency, open alerts, WalletConnect

/metrics is off by default. Set [metrics] token (16 characters or more, or the environment variable FLOWPAY_METRICS__TOKEN) to enable it; scrapers must send Authorization: Bearer <token>.

Terminal window
curl -fsS localhost:8080/healthz
curl -fsS localhost:8080/readyz

Read logs with docker compose logs app; the example configuration writes JSON lines.

Terminal window
docker compose --env-file deploy/.env exec -T postgres pg_dump -U flowpay flowpay > flowpay.sql
  • In production, enable PostgreSQL WAL archiving for point-in-time recovery.
  • On-chain data can be restored by the indexer rescanning from the block the contracts were deployed at.
  • Keep these apart from each other: database backups, the master key, and the offline backups of the quote signer keys (JSON keystores: the secp256k1 key for EVM and TRON, the ed25519 key for Solana) and their passwords.
  • After a master key rotation, keep the old master key until the oldest database backup that may still be restored has expired; those backups are encrypted under it.
  1. Back up the database.

  2. Update the code, rebuild the image and restart:

    Terminal window
    git pull && docker compose --env-file deploy/.env up -d --build

    With a registry image, set FLOWPAY_IMAGE and add --no-build.

  3. Database migrations run automatically at startup (migrate_on_start = true).