From bab18a02c6c04bae207fe520bf5f74f7a78cc71a Mon Sep 17 00:00:00 2001 From: Alberto Ferrer Date: Thu, 6 Mar 2025 10:58:24 -0600 Subject: [PATCH 1/2] Update deploying.md Added a wrapper & uvicorn example. --- docs/concepts/deploying.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/concepts/deploying.md b/docs/concepts/deploying.md index 0b6f64c92..3f1450523 100644 --- a/docs/concepts/deploying.md +++ b/docs/concepts/deploying.md @@ -100,6 +100,20 @@ For example, when we Dockerize the Guardrails API for internal use, our final li ```Dockerfile CMD gunicorn --bind 0.0.0.0:8000 --timeout=90 --workers=4 'guardrails_api.app:create_app(None, "config.py")' ``` +Or using uvicorn, we first create a wrapper: + +```python +# app_wrapper.py +from guardrails_api.app import create_app + +app = create_app(None, "config.py") +``` + +And then we invoke the wrapper: + +```bash +CMD uv run uvicorn app_wrapper:app --host 0.0.0.0 --port 8000 +``` This line starts the Guardrails API Flask application with a gunicorn WSGI server. It specifies what port to bind the server to, as well as the timeout for workers and the maximum number of worker threads for handling requests. @@ -130,4 +144,4 @@ For example, you should define your Guards in the `config.py` that is loaded ont Go ahead and deploy your dockerized Guardrails server on any cloud! We have guides on how to deploy Guardrails on specific clouds. -- [Deploying Guardrails on AWS](https://www.guardrailsai.com/docs/how_to_guides/deploying_aws) \ No newline at end of file +- [Deploying Guardrails on AWS](https://www.guardrailsai.com/docs/how_to_guides/deploying_aws) From dc024ed006b898557c527595c6014e34382aee71 Mon Sep 17 00:00:00 2001 From: Alberto Ferrer Date: Thu, 6 Mar 2025 10:59:31 -0600 Subject: [PATCH 2/2] Update deploying.md Removed uv, directly call uvicorn. --- docs/concepts/deploying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/concepts/deploying.md b/docs/concepts/deploying.md index 3f1450523..91099152e 100644 --- a/docs/concepts/deploying.md +++ b/docs/concepts/deploying.md @@ -112,7 +112,7 @@ app = create_app(None, "config.py") And then we invoke the wrapper: ```bash -CMD uv run uvicorn app_wrapper:app --host 0.0.0.0 --port 8000 +CMD uvicorn app_wrapper:app --host 0.0.0.0 --port 8000 ``` This line starts the Guardrails API Flask application with a gunicorn WSGI server. It specifies what port to bind the server to, as well as the timeout for workers and the maximum number of worker threads for handling requests.