-
-
Notifications
You must be signed in to change notification settings - Fork 614
fly.io Deployment
Falko Schindler edited this page Sep 14, 2023
·
15 revisions
This tutorial demonstrates how to deploy a NiceGUI application on Fly.io.
Create a Python file main.py
with the following content:
from nicegui import ui
from quotes import Quotes
quotes = Quotes()
ui.button('Quote', on_click=lambda: ui.notify(quotes.random()[1]))
ui.run()
Create a Dockerfile
which describes the setup of your app:
FROM zauberzeug/nicegui:1.3.13
RUN pip install --no-cache-dir quotes
COPY . /app
It's good practice to define a concrete version number instead of zauberzeug/nicegui:latest, to ensure you do not run into version conflicts if you deploy again in a few weeks (and latest
may have changed).
- Install flyctl, the command line interface (CLI) to administer your fly.io deployment.
- Create an account with the terminal command
fly auth signup
or login withfly auth login
. - Run
fly launch
from inside your project source directory. It will ask for a unique app name and some other information to create, configure, and deploy your new application.
The fly launch
command creates a fly.toml
file which describes your configuration and should resist in your project root directory under version control.
It should look similar to this:
app = "my-test-app-name"
primary_region = "fra"
[build]
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
Your app is ready to access on https://my-test-app-name.fly.dev/, but of course with your unique app name.