Przeglądaj źródła

#355 moving docker deployment to website

Rodja Trappe 2 lat temu
rodzic
commit
e93753f111
2 zmienionych plików z 43 dodań i 33 usunięć
  1. 0 32
      README.md
  2. 43 1
      website/reference.py

+ 0 - 32
README.md

@@ -104,35 +104,3 @@ docker run --rm -p 8888:8080 -v $(pwd):/app/ -it zauberzeug/nicegui:latest
 This will start the server at http://localhost:8888 with the code from your current directory.
 The file containing your `ui.run(port=8080, ...)` command must be named `main.py`.
 Code modification triggers an automatic reload.
-
-## Deployment
-
-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).
-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/).

+ 43 - 1
website/reference.py

@@ -2,8 +2,9 @@ import uuid
 from typing import Dict
 
 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())
 
@@ -958,3 +959,44 @@ You can set the following environment variables to configure NiceGUI:
         from nicegui.elements import markdown
 
         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)