From 19ef4d592bf519cdd53acb48cb0d21436e9bb61f Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Fri, 6 Mar 2026 21:00:59 +0100 Subject: [PATCH] refactor: simplify env configuration with single port definitions - Update docker-compose.yml healthchecks to use env variables instead of hardcoded ports - Restructure .env.example to define each port only once - Auto-generate service URLs from port variables using ${PORT} syntax - Document the configuration structure with clear sections - Makes it easier to change ports without updating multiple variables --- .env.example | 45 +++++++++++++++++++++------------------- infra/docker-compose.yml | 8 +++---- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.env.example b/.env.example index 2548119..a575ff5 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,10 @@ # Stripstream Librarian - Environment Configuration +# +# HOW TO USE: +# 1. Copy this file to .env: cp .env.example .env +# 2. Change the REQUIRED values below +# 3. Optionally change ports if you have conflicts +# 4. Run: docker-compose up --build # ============================================================================= # REQUIRED - Change these values in production! @@ -12,41 +18,38 @@ MEILI_MASTER_KEY=change-me-in-production API_BOOTSTRAP_TOKEN=change-me-in-production # ============================================================================= -# Services Configuration +# Port Configuration (change only if you have port conflicts) # ============================================================================= -# API Service -API_LISTEN_ADDR=0.0.0.0:8080 -API_BASE_URL=http://api:8080 +# Main application ports API_PORT=8080 - -# Indexer Service -INDEXER_LISTEN_ADDR=0.0.0.0:8081 -INDEXER_SCAN_INTERVAL_SECONDS=5 INDEXER_PORT=8081 - -# Backoffice Web UI BACKOFFICE_PORT=8082 -# Meilisearch Search Engine +# Infrastructure ports MEILI_PORT=7700 - -# PostgreSQL Database POSTGRES_PORT=5432 # ============================================================================= -# Database Configuration +# Service URLs (auto-generated from ports above - don't change unless you know what you're doing) # ============================================================================= -# PostgreSQL connection string -DATABASE_URL=postgres://stripstream:stripstream@postgres:5432/stripstream +# API Service +API_LISTEN_ADDR=0.0.0.0:${API_PORT} +API_BASE_URL=http://api:${API_PORT} -# ============================================================================= -# Search Configuration -# ============================================================================= +# Indexer Service +INDEXER_LISTEN_ADDR=0.0.0.0:${INDEXER_PORT} +INDEXER_SCAN_INTERVAL_SECONDS=5 -# Meilisearch connection URL -MEILI_URL=http://meilisearch:7700 +# Backoffice Web UI +# Uses BACKOFFICE_PORT from above + +# Meilisearch Search Engine +MEILI_URL=http://meilisearch:${MEILI_PORT} + +# PostgreSQL Database +DATABASE_URL=postgres://stripstream:stripstream@postgres:${POSTGRES_PORT}/stripstream # ============================================================================= # Storage Configuration diff --git a/infra/docker-compose.yml b/infra/docker-compose.yml index f27f419..d5c7612 100644 --- a/infra/docker-compose.yml +++ b/infra/docker-compose.yml @@ -24,7 +24,7 @@ services: volumes: - meili_data:/meili_data healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:7700/health"] + test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:${MEILI_PORT:-7700}/health"] interval: 10s timeout: 5s retries: 5 @@ -65,7 +65,7 @@ services: meilisearch: condition: service_healthy healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:8080/health"] + test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:${API_PORT:-8080}/health"] interval: 10s timeout: 5s retries: 5 @@ -88,7 +88,7 @@ services: meilisearch: condition: service_healthy healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:8081/health"] + test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:${INDEXER_PORT:-8081}/health"] interval: 10s timeout: 5s retries: 5 @@ -108,7 +108,7 @@ services: api: condition: service_healthy healthcheck: - test: ["CMD", "wget", "-q", "-O", "-", "http://host.docker.internal:8082/health"] + test: ["CMD", "wget", "-q", "-O", "-", "http://host.docker.internal:${BACKOFFICE_PORT:-8082}/health"] interval: 10s timeout: 5s retries: 5