From 5f531ba55eadc7061bb4da70f0560718a8c31727 Mon Sep 17 00:00:00 2001 From: jimmoffet <jim.moffet@gsa.gov> Date: Sun, 22 Sep 2024 10:09:18 -0700 Subject: [PATCH] postgres --- TODO.md | 7 +++---- backend/config.py | 11 +++++++++-- docker-compose.yml | 11 +++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 docker-compose.yml diff --git a/TODO.md b/TODO.md index f09ea6e95..7135f01e4 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,8 @@ # TODOs -- Integrate cloud SSO -- Use postgres for db -- Build step during CI. -- Consider checking for state and code in front-end auth route and then redirecting to /auth (and clearing params) on any auth failures. This will allow us to avoid flashing the sign in screen before showing "signing into ai sandbox..." +- Workspace > documents needs a spinner when processing docs +- existing tags should be selectable when adding to docs +- Chroma is kept in ram... need to swap for redis - Save and retrieve valves.json data from env instead of json - Remove pipeline add from admin settings > pipelines - Investigation RAG set up diff --git a/backend/config.py b/backend/config.py index 8eff3a285..dc453fe45 100644 --- a/backend/config.py +++ b/backend/config.py @@ -311,6 +311,7 @@ def __getattr__(self, key): "cloud-gov-identity-provider" ][0]["credentials"]["client_secret"] + OAUTH2_PROVIDERS = { # Example provider configuration "github": { @@ -1169,5 +1170,11 @@ class BannerModel(BaseModel): #################################### # Database #################################### - -DATABASE_URL = os.environ.get("DATABASE_URL", f"sqlite:///{DATA_DIR}/webui.db") +if os.environ.get("VCAP_SERVICES"): + vcap_services = json.loads(os.getenv("VCAP_SERVICES")) + if (vcap_services and "aws-rds" in vcap_services) and not os.getenv( + "DATABASE_URL", None + ): + os.environ["DATABASE_URL"] = vcap_services["aws-rds"][0]["credentials"]["uri"] +else: + DATABASE_URL = os.environ.get("DATABASE_URL", f"sqlite:///{DATA_DIR}/webui.db") diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..6f94849cd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.1' + +services: + db: + image: postgres:latest + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ai_sandbox + ports: + - "5432:5432" \ No newline at end of file