Skip to content

Commit 0af3d94

Browse files
[CHORE] Consolidate env config into single common.env with zero duplication
- Create docker/sample.common.env as single source of truth for all shared env vars (DB, Redis, RabbitMQ, MinIO, Flipt, service URLs, timeouts) - Remove docker/sample.essentials.env (merged into common.env) - Eliminate credential duplication by using Docker Compose environment mappings to derive infra vars from app vars (e.g. POSTGRES_USER from DB_USER, RABBITMQ_DEFAULT_USER from CELERY_BROKER_USER) - Standardize DB env var names across services: PG_BE_* -> DB_*, DB_USERNAME -> DB_USER, REDIS_USERNAME -> REDIS_USER - Strip shared vars from per-service sample.env files (backend, workers, prompt-service, runner, platform-service, x2text-service) - Update docker-compose files to use .env (auto-read by Docker Compose for variable substitution) - Update docker/README.md with simplified setup instructions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d645846 commit 0af3d94

File tree

17 files changed

+239
-309
lines changed

17 files changed

+239
-309
lines changed

backend/sample.env

Lines changed: 7 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# -----------------------------------------------------------------------------
2+
# LOCAL DEVELOPMENT NOTE:
3+
# Shared env vars (DB, Redis, RabbitMQ, Flipt, service URLs, MinIO, timeouts)
4+
# live in docker/sample.common.env. When running outside Docker, copy those vars
5+
# here and replace container hostnames with localhost (see common.env header).
6+
# -----------------------------------------------------------------------------
7+
18
DJANGO_SETTINGS_MODULE='backend.settings.dev'
29

310
# NOTE: Change below to True if you are running in HTTPS mode.
@@ -14,22 +21,9 @@ PATH_PREFIX="api/v1"
1421
DJANGO_APP_BACKEND_URL=http://frontend.unstract.localhost
1522
DJANGO_SECRET_KEY="1(xf&nc6!y7!l&!5xe&i_rx7e^m@fcut9fduv86ft=-b@2g6"
1623

17-
# Postgres DB envs
18-
DB_HOST='unstract-db'
19-
DB_USER='unstract_dev'
20-
DB_PASSWORD='unstract_pass'
21-
DB_NAME='unstract_db'
22-
DB_PORT=5432
23-
DB_SCHEMA="unstract"
24-
2524
# Celery Backend Database (optional - defaults to DB_NAME if unset)
2625
# Example:
2726
# CELERY_BACKEND_DB_NAME=unstract_celery_db
28-
# Redis
29-
REDIS_HOST="unstract-redis"
30-
REDIS_PORT=6379
31-
REDIS_PASSWORD=""
32-
REDIS_USER=default
3327

3428
# Redis Retry Configuration
3529
# Controls automatic retry behavior for transient Redis connection failures
@@ -74,20 +68,6 @@ GOOGLE_STORAGE_ACCESS_KEY_ID=
7468
GOOGLE_STORAGE_SECRET_ACCESS_KEY=
7569
GOOGLE_STORAGE_BASE_URL=https://storage.googleapis.com
7670

77-
# Platform Service
78-
PLATFORM_SERVICE_HOST=http://unstract-platform-service
79-
PLATFORM_SERVICE_PORT=3001
80-
81-
# Tool Runner
82-
UNSTRACT_RUNNER_HOST=http://unstract-runner
83-
UNSTRACT_RUNNER_PORT=5002
84-
UNSTRACT_RUNNER_API_TIMEOUT=240 # (in seconds) 2 mins
85-
UNSTRACT_RUNNER_API_RETRY_COUNT=5 # Number of retries for failed requests
86-
UNSTRACT_RUNNER_API_BACKOFF_FACTOR=3 # Exponential backoff factor for retries
87-
88-
# Prompt Service
89-
PROMPT_HOST=http://unstract-prompt-service
90-
PROMPT_PORT=3003
9171

9272
#Prompt Studio
9373
PROMPT_STUDIO_FILE_PATH=/app/prompt-studio-data
@@ -98,15 +78,6 @@ STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.97"
9878
STRUCTURE_TOOL_IMAGE_NAME="unstract/tool-structure"
9979
STRUCTURE_TOOL_IMAGE_TAG="0.0.97"
10080

101-
# Feature Flags
102-
EVALUATION_SERVER_IP=unstract-flipt
103-
EVALUATION_SERVER_PORT=9000
104-
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
105-
106-
107-
#X2Text Service
108-
X2TEXT_HOST=http://unstract-x2text-service
109-
X2TEXT_PORT=3004
11081

11182
# Encryption Key
11283
# Key must be 32 url-safe base64-encoded bytes. Check the README.md for details
@@ -142,29 +113,13 @@ SYSTEM_ADMIN_EMAIL="admin@abc.com"
142113
# Set Django Session Expiry Time (in seconds)
143114
SESSION_COOKIE_AGE=86400
144115

145-
# Control async extraction of LLMWhisperer
146-
# Time in seconds to wait before polling LLMWhisperer's status API
147-
ADAPTER_LLMW_POLL_INTERVAL=30
148-
# Total number of times to poll the status API.
149-
# 500 mins to allow 1500 (max pages limit) * 20 (approx time in sec to process a page)
150-
ADAPTER_LLMW_MAX_POLLS=1000
151-
# Number of times to retry the /whisper-status API before failing the extraction
152-
ADAPTER_LLMW_STATUS_RETRIES=5
153116

154117
# Enable logging of workflow history.
155118
ENABLE_LOG_HISTORY=True
156119
# Interval in seconds for periodic consumer operations.
157120
LOG_HISTORY_CONSUMER_INTERVAL=30
158121
# Maximum number of logs to insert in a single batch.
159122
LOGS_BATCH_LIMIT=30
160-
# Logs Expiry of 24 hours
161-
LOGS_EXPIRATION_TIME_IN_SECOND=86400
162-
163-
# Celery Configuration
164-
# Used by celery and to connect to queue to push logs
165-
CELERY_BROKER_BASE_URL="amqp://unstract-rabbitmq:5672//"
166-
CELERY_BROKER_USER=admin
167-
CELERY_BROKER_PASS=password
168123

169124
# Indexing flag to prevent re-index
170125
INDEXING_FLAG_TTL=1800
@@ -176,25 +131,6 @@ NOTIFICATION_TIMEOUT=5
176131
# with a YAML and JSONs
177132
TOOL_REGISTRY_CONFIG_PATH="/data/tool_registry_config"
178133

179-
# Flipt Service
180-
FLIPT_SERVICE_AVAILABLE=False
181-
182-
# File System Configuration for Workflow and API Execution
183-
184-
# Directory Prefixes for storing execution files
185-
WORKFLOW_EXECUTION_DIR_PREFIX="unstract/execution"
186-
API_EXECUTION_DIR_PREFIX="unstract/api"
187-
188-
# Storage Provider for Workflow Execution
189-
# Valid options: MINIO, S3, etc..
190-
WORKFLOW_EXECUTION_FILE_STORAGE_CREDENTIALS='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'
191-
192-
# Storage Provider for API Execution
193-
API_FILE_STORAGE_CREDENTIALS='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'
194-
195-
#Remote storage related envs
196-
PERMANENT_REMOTE_STORAGE='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'
197-
REMOTE_PROMPT_STUDIO_FILE_PATH="unstract/prompt-studio-data"
198134

199135
# Storage Provider for Tool registry
200136
TOOL_REGISTRY_STORAGE_CREDENTIALS='{"provider":"local"}'

docker/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,21 @@ VERSION=dev docker compose -f docker-compose.build.yaml --profile optional build
1515

1616
## Docker Run
1717

18-
**NOTE**: First copy `sample.*.env` files to `*.env` and update as required.
18+
**NOTE**: Before running, set up your env files:
19+
20+
```bash
21+
# 1. Common env vars shared across all services and infrastructure
22+
# (DB, Redis, RabbitMQ, Flipt, MinIO, service URLs, timeouts)
23+
cp docker/sample.common.env docker/.env
24+
25+
# 2. Per-service env files (service-specific settings only)
26+
cp backend/sample.env backend/.env
27+
cp platform-service/sample.env platform-service/.env
28+
cp prompt-service/sample.env prompt-service/.env
29+
cp x2text-service/sample.env x2text-service/.env
30+
cp runner/sample.env runner/.env
31+
cp workers/sample.env workers/.env
32+
```
1933

2034
```bash
2135
# Up all services

docker/docker-compose-dev-essentials.yaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ services:
1111
- postgres_data:/var/lib/postgresql/data/
1212
- ./scripts/db-setup/db_setup.sh:/docker-entrypoint-initdb.d/db_setup.sh
1313
env_file:
14-
- ./essentials.env
14+
- ./.env
15+
environment:
16+
# Map app DB_* vars to Postgres container's expected POSTGRES_* vars
17+
POSTGRES_USER: ${DB_USER}
18+
POSTGRES_PASSWORD: ${DB_PASSWORD}
19+
POSTGRES_DB: ${DB_NAME}
20+
POSTGRES_SCHEMA: ${DB_SCHEMA}
1521
labels:
1622
- traefik.enable=false
1723

@@ -39,7 +45,7 @@ services:
3945
volumes:
4046
- minio_data:/data
4147
env_file:
42-
- ./essentials.env
48+
- ./.env
4349
command: server /data --console-address ":9001"
4450
labels:
4551
- traefik.enable=true
@@ -100,6 +106,14 @@ services:
100106
- "9005:9000" # gRPC port
101107
volumes:
102108
- flipt_data:/var/opt/flipt
109+
# https://www.flipt.io/docs/configuration/overview#environment-variables)
110+
# https://www.flipt.io/docs/configuration/overview#configuration-parameters
111+
env_file:
112+
- ./.env
113+
environment:
114+
FLIPT_CACHE_ENABLED: true
115+
# Flipt DB connection derived from app DB_* vars
116+
FLIPT_DB_URL: "postgres://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}?sslmode=disable"
103117
labels:
104118
- traefik.enable=true
105119
- traefik.http.routers.feature-flag.rule=Host(`feature-flag.unstract.localhost`)
@@ -128,15 +142,19 @@ services:
128142
labels:
129143
- traefik.enable=false
130144
env_file:
131-
- ./essentials.env
145+
- ./.env
132146

133147
rabbitmq:
134148
image: rabbitmq:4.1.0-management
135149
container_name: unstract-rabbitmq
136150
hostname: unstract-rabbit
137151
restart: unless-stopped
138152
env_file:
139-
- ./essentials.env
153+
- ./.env
154+
environment:
155+
# Map app CELERY_BROKER_* vars to RabbitMQ container's expected vars
156+
RABBITMQ_DEFAULT_USER: ${CELERY_BROKER_USER}
157+
RABBITMQ_DEFAULT_PASS: ${CELERY_BROKER_PASS}
140158
ports:
141159
- "5672:5672" # AMQP port
142160
- "15672:15672" # Management UI port

0 commit comments

Comments
 (0)