From f1e194ddd61fa22d55d7e8c3df9e223cf0e0a362 Mon Sep 17 00:00:00 2001 From: manshusainishab Date: Sun, 22 Feb 2026 02:16:48 +0530 Subject: [PATCH 1/3] docs: add .env.example and document environment configuration --- .env.example | 40 ++++++++++++++++++++++++++++++++++++++++ README.md | 37 +++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..071038741 --- /dev/null +++ b/.env.example @@ -0,0 +1,40 @@ +# Note: Remember to replace the placeholder values with your actual configuration settings before running the application. + +# Database + +DEV_DATABASE_URL=postgresql://user:password@localhost:5432/opencre + +# Neo4j + +NEO4J_URL=neo4j://neo4j:password@localhost:7687 + +# Redis + +REDIS_HOST=localhost +REDIS_PORT=6379 +REDIS_URL=redis://localhost:6379 +REDIS_NO_SSL=false + +# Flask + +FLASK_CONFIG=development +INSECURE_REQUESTS=false + +# Embeddings + +NO_GEN_EMBEDDINGS=false + +# Google Auth + +GOOGLE_CLIENT_ID=your-client-id +GOOGLE_CLIENT_SECRET=your-client-secret +GOOGLE_SECRET_JSON=path/to/secret.json +LOGIN_ALLOWED_DOMAINS=example.com + +# GCP + +GCP_NATIVE=false + +# Spreadsheet Auth + +OpenCRE_gspread_Auth=path/to/credentials.json diff --git a/README.md b/README.md index 57b73ae6a..13a4fcdfb 100644 --- a/README.md +++ b/README.md @@ -216,23 +216,28 @@ make docker-dev The environment variables used by OpenCRE are: +## Environment Configuration + +Copy the example configuration file: + +```bash +cp .env.example .env ``` -- NEO4J_URL -- NO_GEN_EMBEDDINGS -- FLASK_CONFIG -- DEV_DATABASE_URL -- INSECURE_REQUESTS -- REDIS_HOST -- REDIS_PORT -- REDIS_NO_SSL -- REDIS_URL -- GCP_NATIVE -- GOOGLE_SECRET_JSON -- GOOGLE_CLIENT_ID -- GOOGLE_CLIENT_SECRET -- LOGIN_ALLOWED_DOMAINS -- OpenCRE_gspread_Auth -``` + +Then edit `.env` and provide values appropriate for your environment. + +### Variables + +* Database: `DEV_DATABASE_URL` +* Neo4j: `NEO4J_URL` +* Redis: `REDIS_HOST`, `REDIS_PORT`, `REDIS_URL`, `REDIS_NO_SSL` +* Flask: `FLASK_CONFIG`, `INSECURE_REQUESTS` +* Embeddings: `NO_GEN_EMBEDDINGS` +* Google Auth: `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, `GOOGLE_SECRET_JSON`, `LOGIN_ALLOWED_DOMAINS` +* GCP: `GCP_NATIVE` +* Spreadsheet Auth: `OpenCRE_gspread_Auth` + +See `.env.example` for full list and defaults. You can run the containers with: From 5eb69c4f827f482c68ea9ec3e6ac2f255e54c23d Mon Sep 17 00:00:00 2001 From: manshusainishab Date: Fri, 27 Feb 2026 04:02:20 +0530 Subject: [PATCH 2/3] feat: automatically load environment variables from `.env` for local development and update `.env.example` comments. --- .env.example | 8 ++++++-- cre.py | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 071038741..0ebe342ac 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,9 @@ -# Note: Remember to replace the placeholder values with your actual configuration settings before running the application. - +# ------------------------------------------------------------------------------ +# OpenCRE Environment Configuration +# ------------------------------------------------------------------------------ +# Copy this file to `.env` and update the values for your environment. +# Never commit your real `.env` file to version control. +# ------------------------------------------------------------------------------ # Database DEV_DATABASE_URL=postgresql://user:password@localhost:5432/opencre diff --git a/cre.py b/cre.py index 97e919c14..e3dba246f 100644 --- a/cre.py +++ b/cre.py @@ -4,6 +4,14 @@ import unittest from typing import List +# NEW: load .env automatically for local development +try: + from dotenv import load_dotenv # type: ignore + + load_dotenv() +except ImportError: + pass + import click # type: ignore import coverage # type: ignore from flask_migrate import Migrate # type: ignore From 2a0927a27a3d2c719bb54a095c6d51cc659c8ba0 Mon Sep 17 00:00:00 2001 From: manshusainishab Date: Fri, 27 Feb 2026 04:08:11 +0530 Subject: [PATCH 3/3] style: Remove trailing whitespace from `load_dotenv()` call. --- cre.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cre.py b/cre.py index e3dba246f..2e7a9d5cc 100644 --- a/cre.py +++ b/cre.py @@ -8,7 +8,7 @@ try: from dotenv import load_dotenv # type: ignore - load_dotenv() + load_dotenv() except ImportError: pass