From 02e72d910754baa8cc86b3553b9ebd874b5db358 Mon Sep 17 00:00:00 2001 From: Salzkammercode <64585793+UranymusDev@users.noreply.github.com> Date: Fri, 29 Aug 2025 13:42:04 +0200 Subject: [PATCH] fix: resolve container startup race condition in agents service (#451) (#503) * depends on and env var added Update Vite configuration to enable allowed hosts - Uncommented the allowedHosts configuration to allow for dynamic host settings based on environment variables. - This change enhances flexibility for different deployment environments while maintaining the default localhost and specific domain access. Needs testing to confirm proper functionality with various host configurations. rm my domain * Enhance Vite configuration with dynamic allowed hosts support - Added VITE_ALLOWED_HOSTS environment variable to .env.example and docker-compose.yml for flexible host configuration. - Updated Vite config to dynamically set allowed hosts, incorporating defaults and custom values from the environment variable. - This change improves deployment flexibility while maintaining security by defaulting to localhost and specific domains. Needs testing to confirm proper functionality with various host configurations. * refactor: remove unnecessary dependency on archon-agents in docker-compose.yml - Removed the dependency condition for archon-agents from the archon-mcp service to streamline the startup process. - This change simplifies the service configuration and reduces potential startup issues related to agent service health checks. Needs testing to ensure that the application functions correctly without the archon-agents dependency. --------- Co-authored-by: Julian Gegenhuber --- .env.example | 6 ++++++ archon-ui-main/vite.config.ts | 11 ++++++++++- docker-compose.yml | 9 +++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index c141ae29..dc00d2e6 100644 --- a/.env.example +++ b/.env.example @@ -36,6 +36,12 @@ ARCHON_AGENTS_PORT=8052 ARCHON_UI_PORT=3737 ARCHON_DOCS_PORT=3838 +# Frontend Configuration +# VITE_ALLOWED_HOSTS: Comma-separated list of additional hosts allowed for Vite dev server +# Example: VITE_ALLOWED_HOSTS=192.168.1.100,myhost.local,example.com +# If not set, defaults to localhost, 127.0.0.1, ::1, and the HOST value above +VITE_ALLOWED_HOSTS= + # When enabled, PROD mode will proxy ARCHON_SERVER_PORT through ARCHON_UI_PORT. This exposes both the # Archon UI and API through a single port. This is useful when deploying Archon behind a reverse # proxy where you want to expose the frontend on a single external domain. diff --git a/archon-ui-main/vite.config.ts b/archon-ui-main/vite.config.ts index c257275f..0626fb28 100644 --- a/archon-ui-main/vite.config.ts +++ b/archon-ui-main/vite.config.ts @@ -280,7 +280,16 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { host: '0.0.0.0', // Listen on all network interfaces with explicit IP port: parseInt(process.env.ARCHON_UI_PORT || env.ARCHON_UI_PORT || '3737'), // Use configurable port strictPort: true, // Exit if port is in use - allowedHosts: [env.HOST, 'localhost', '127.0.0.1'], + allowedHosts: (() => { + const defaultHosts = ['localhost', '127.0.0.1', '::1']; + const customHosts = env.VITE_ALLOWED_HOSTS?.trim() + ? env.VITE_ALLOWED_HOSTS.split(',').map(h => h.trim()).filter(Boolean) + : []; + const hostFromEnv = (process.env.HOST ?? env.HOST) && (process.env.HOST ?? env.HOST) !== 'localhost' + ? [process.env.HOST ?? env.HOST] + : []; + return [...new Set([...defaultHosts, ...hostFromEnv, ...customHosts])]; + })(), proxy: { '/api': { target: `http://${host}:${port}`, diff --git a/docker-compose.yml b/docker-compose.yml index 962c6dbf..a15b15fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,7 +89,9 @@ services: networks: - app-network depends_on: - - archon-server + archon-server: + condition: service_healthy + extra_hosts: - "host.docker.internal:host-gateway" healthcheck: @@ -126,6 +128,7 @@ services: - SERVICE_DISCOVERY_MODE=docker_compose - LOG_LEVEL=${LOG_LEVEL:-INFO} - ARCHON_AGENTS_PORT=${ARCHON_AGENTS_PORT:-8052} + - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} networks: - app-network healthcheck: @@ -153,6 +156,7 @@ services: - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} - HOST=${HOST:-localhost} - PROD=${PROD:-false} + - VITE_ALLOWED_HOSTS=${VITE_ALLOWED_HOSTS:-} networks: - app-network healthcheck: @@ -164,7 +168,8 @@ services: - ./archon-ui-main/src:/app/src - ./archon-ui-main/public:/app/public depends_on: - - archon-server + archon-server: + condition: service_healthy networks: app-network: