Fly.io
Fly.io works well for Flet apps: it supports WebSockets, deploys close to users via multiple regions, and has a free tier suitable for small projects.
Prerequisites#
- Install flyctl.
- Authenticate:
Project files#
Place the following files in your app directory.
requirements.txt#
At minimum:
fly.toml#
Fly app configuration:
fly.toml
app = "<your-app-name>"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
FLET_SESSION_TIMEOUT = "60"
[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[http_service.concurrency]
type = "connections"
soft_limit = 200
hard_limit = 250
- Replace
<your-app-name>with the app name you want. It will also be used in the final URL of your app, in the form,https://<your-app-name>.fly.dev. internal_portmust correspond to theFLET_SERVER_PORT, which is8000by default.FLET_SESSION_TIMEOUTcontrols session lifetime (seconds).- For other variables, see environment variables reference.
Dockerfile#
Create a Dockerfile containing the commands to build your application container,
for example:
Dockerfile
FROM python:3-alpine
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "main.py"]
main.py is the app's entry point. If your file name differs, update accordingly.
Info
Fly.io deploys apps as Docker containers and provides a free remote Docker builder, so you don’t need Docker installed locally.
Deploy#
From your app directory:
-
Create the Fly app:
-
Deploy:
-
Open app in browser: