website/docs/publish/web/dynamic-website/hosting/fly-io.md
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.
fly auth login
Place the following files in your app directory.
requirements.txtAt minimum:
flet
fly.tomlFly app configuration:
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
<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_port must correspond to the FLET_SERVER_PORT, which is 8000 by default.FLET_SESSION_TIMEOUT controls session lifetime (seconds).DockerfileCreate a Dockerfile containing the commands to build your application container,
for example:
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[Info] Fly.io deploys apps as Docker containers and provides a free remote Docker builder, so you don’t need Docker installed locally. :::
From your app directory:
Create the Fly app:
fly apps create --name <your-app-name>
Deploy:
fly deploy
Open app in browser:
fly apps open