|
@@ -2,8 +2,9 @@ import uuid
|
|
from typing import Dict
|
|
from typing import Dict
|
|
|
|
|
|
from nicegui import app, ui
|
|
from nicegui import app, ui
|
|
|
|
+from nicegui.elements.markdown import prepare_content
|
|
|
|
|
|
-from .example import example
|
|
|
|
|
|
+from .example import add_html_with_anchor_link, example
|
|
|
|
|
|
CONSTANT_UUID = str(uuid.uuid4())
|
|
CONSTANT_UUID = str(uuid.uuid4())
|
|
|
|
|
|
@@ -958,3 +959,44 @@ You can set the following environment variables to configure NiceGUI:
|
|
from nicegui.elements import markdown
|
|
from nicegui.elements import markdown
|
|
|
|
|
|
ui.label(f'Markdown content cache size is {markdown.prepare_content.cache_info().maxsize}')
|
|
ui.label(f'Markdown content cache size is {markdown.prepare_content.cache_info().maxsize}')
|
|
|
|
+
|
|
|
|
+ h3('Deployment')
|
|
|
|
+
|
|
|
|
+ ui.html(prepare_content('''
|
|
|
|
+To deploy your NiceGUI app, you will need to execute your `main.py` (or whichever file contains your `ui.run(...)`) on your server infrastructure.
|
|
|
|
+You can either install the [NiceGUI python package via pip](https://pypi.org/project/nicegui/) on the server
|
|
|
|
+or use our [pre-built Docker image](https://hub.docker.com/r/zauberzeug/nicegui) which contains all necessary dependencies (see above).
|
|
|
|
+ ''', ''))
|
|
|
|
+
|
|
|
|
+ with ui.column().classes('w-full mb-8'):
|
|
|
|
+ docker = '''#### Docker
|
|
|
|
+
|
|
|
|
+For example you can use this `docker run` command to start the script `main.py` in the current directory on port 80:
|
|
|
|
+
|
|
|
|
+```bash
|
|
|
|
+docker run -p 80:8080 -v $(pwd)/:/app/ -d --restart always zauberzeug/nicegui:latest
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+The example assumes `main.py` uses the port 8080 in the `ui.run` command (which is the default).
|
|
|
|
+The `--restart always` makes sure the container is restarted if the app crashes or the server reboots.
|
|
|
|
+Of course this can also be written in a Docker compose file:
|
|
|
|
+
|
|
|
|
+```yaml
|
|
|
|
+nicegui:
|
|
|
|
+ image: zauberzeug/nicegui:latest
|
|
|
|
+ restart: always
|
|
|
|
+ ports:
|
|
|
|
+ - 80:8080
|
|
|
|
+ volumes:
|
|
|
|
+ - ./:/app/
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+You can provide SSL certificates directly using [FastAPI](https://fastapi.tiangolo.com/deployment/https/).
|
|
|
|
+In production we also like using reverse proxies like [Traefik](https://doc.traefik.io/traefik/) or [NGINX](https://www.nginx.com/) to handle these details for us.
|
|
|
|
+See our [docker-compose.yml](https://github.com/zauberzeug/nicegui/blob/main/docker-compose.yml) as an example.
|
|
|
|
+
|
|
|
|
+You may also have look at [our example for using a custom FastAPI app](https://github.com/zauberzeug/nicegui/tree/main/examples/fastapi).
|
|
|
|
+This will allow you to do very flexible deployments as described in the [FastAPI documentation](https://fastapi.tiangolo.com/deployment/).
|
|
|
|
+
|
|
|
|
+ '''
|
|
|
|
+ add_html_with_anchor_link(prepare_content(docker, 'fenced-code-blocks'), menu)
|