diff --git a/configuration/n8n-workflows/GHOSTS Belief.json b/configuration/n8n-workflows/GHOSTS Belief.json index 992d887dd..82c15430f 100644 --- a/configuration/n8n-workflows/GHOSTS Belief.json +++ b/configuration/n8n-workflows/GHOSTS Belief.json @@ -23,7 +23,7 @@ }, { "parameters": { - "url": "http://host.docker.internal:5000/api/npcs/list", + "url": "http://ghosts-api:5000/api/npcs/list", "options": {} }, "id": "48501b3a-05f9-4067-bf55-d859110a13a9", @@ -64,7 +64,7 @@ }, { "parameters": { - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.id }}/beliefs", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.id }}/beliefs", "options": {} }, "id": "5736842c-326f-47a1-920a-8b4a53d67e2e", @@ -94,7 +94,7 @@ { "parameters": { "method": "POST", - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.npcId }}/beliefs", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.npcId }}/beliefs", "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"toNpcId\": \"{{ $json.npcId }}\",\n \"fromNpcId\": \"{{ $json.npcId }}\",\n \"name\": \"{{ $json.name }}\",\n \"step\": {{ $json.step }},\n \"likelihood\": {{ $json.likelihood }},\n \"posterior\": {{ $json.posterior }}\n}", diff --git a/configuration/n8n-workflows/GHOSTS Connections.json b/configuration/n8n-workflows/GHOSTS Connections.json index c73023cff..42214c398 100644 --- a/configuration/n8n-workflows/GHOSTS Connections.json +++ b/configuration/n8n-workflows/GHOSTS Connections.json @@ -33,7 +33,7 @@ }, { "parameters": { - "url": "http://host.docker.internal:5000/api/npcs/list", + "url": "http://ghosts-api:5000/api/npcs/list", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -59,7 +59,7 @@ { "parameters": { "method": "POST", - "url": "=http://host.docker.internal:5000/api/npcs/{{ $('Loop Over Items').item.json.id }}/connections", + "url": "=http://ghosts-api:5000/api/npcs/{{ $('Loop Over Items').item.json.id }}/connections", "sendHeaders": true, "headerParameters": { "parameters": [ diff --git a/configuration/n8n-workflows/GHOSTS Post to Social Media.json b/configuration/n8n-workflows/GHOSTS Post to Social Media.json index 9794af638..43b8ac966 100644 --- a/configuration/n8n-workflows/GHOSTS Post to Social Media.json +++ b/configuration/n8n-workflows/GHOSTS Post to Social Media.json @@ -70,7 +70,7 @@ }, { "parameters": { - "url": "http://host.docker.internal:5000/api/npcs/list", + "url": "http://ghosts-api:5000/api/npcs/list", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -84,7 +84,7 @@ }, { "parameters": { - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.id }}", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.id }}", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -233,7 +233,7 @@ { "parameters": { "method": "POST", - "url": "=http://host.docker.internal:5000/api/npcs/{{ $('Loop Over Items').item.json.id }}/activity", + "url": "=http://ghosts-api:5000/api/npcs/{{ $('Loop Over Items').item.json.id }}/activity", "sendQuery": true, "queryParameters": { "parameters": [ diff --git a/configuration/n8n-workflows/GHOSTS Preferences.json b/configuration/n8n-workflows/GHOSTS Preferences.json index 9e66e2f28..174e9b919 100644 --- a/configuration/n8n-workflows/GHOSTS Preferences.json +++ b/configuration/n8n-workflows/GHOSTS Preferences.json @@ -70,7 +70,7 @@ }, { "parameters": { - "url": "http://host.docker.internal:5000/api/npcs/list", + "url": "http://ghosts-api:5000/api/npcs/list", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -84,7 +84,7 @@ }, { "parameters": { - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.id }}", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.id }}", "options": {} }, "type": "n8n-nodes-base.httpRequest", @@ -110,7 +110,7 @@ { "parameters": { "method": "POST", - "url": "=http://host.docker.internal:5000/api/npcs/{{ $('Get NPC detail').item.json.id }}/preferences", + "url": "=http://ghosts-api:5000/api/npcs/{{ $('Get NPC detail').item.json.id }}/preferences", "sendHeaders": true, "headerParameters": { "parameters": [ diff --git a/configuration/n8n-workflows/GHOSTS Social Graph.json b/configuration/n8n-workflows/GHOSTS Social Graph.json index 9ee09a6fc..e66ab7fb0 100644 --- a/configuration/n8n-workflows/GHOSTS Social Graph.json +++ b/configuration/n8n-workflows/GHOSTS Social Graph.json @@ -23,7 +23,7 @@ }, { "parameters": { - "url": "http://host.docker.internal:5000/api/npcs/list", + "url": "http://ghosts-api:5000/api/npcs/list", "options": {} }, "id": "bdf0bc40-8254-4442-a16d-8860d6dd183c", @@ -64,7 +64,7 @@ }, { "parameters": { - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.id }}/connections", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.id }}/connections", "options": {} }, "id": "abdac659-73cb-47ec-9df4-d0c5aa10574f", @@ -111,7 +111,7 @@ }, { "parameters": { - "url": "http://host.docker.internal:5000/api/npcs/list", + "url": "http://ghosts-api:5000/api/npcs/list", "options": {} }, "id": "92fcb08f-16f0-4983-a0b2-594bb7f93f6e", @@ -140,7 +140,7 @@ { "parameters": { "method": "POST", - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.npcId }}/connections", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.npcId }}/connections", "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"connectedNpcId\": \"{{ $json.connectedNpcId }}\",\n \"name\": \"{{ $json.name }}\",\n \"distance\": \"\",\n \"relationshipStatus\": 0.0\n}", @@ -172,7 +172,7 @@ }, { "parameters": { - "url": "=http://host.docker.internal:5000/api/npcs/{{ $json.id }}/knowledge", + "url": "=http://ghosts-api:5000/api/npcs/{{ $json.id }}/knowledge", "options": {} }, "id": "6ce5eab2-c9ed-4089-8e0d-29bc924fb21f", @@ -202,7 +202,7 @@ { "parameters": { "method": "POST", - "url": "=http://host.docker.internal:5000/api/npcs/{{ $('Set Id').first().json.id }}/knowledge", + "url": "=http://ghosts-api:5000/api/npcs/{{ $('Set Id').first().json.id }}/knowledge", "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"toNpcId\": \"{{ $json.npcId }}\",\n \"fromNpcId\": \"{{ $json.fromNpcId }}\",\n \"topic\": \"{{ $json.topic }}\",\n \"step\": {{ $json.step }},\n \"value\": {{ $json.value }}\n}", diff --git a/configuration/n8n-workflows/README.md b/configuration/n8n-workflows/README.md index 1617348d3..12f114f3c 100644 --- a/configuration/n8n-workflows/README.md +++ b/configuration/n8n-workflows/README.md @@ -40,8 +40,10 @@ Before importing these workflows, you need to: If you don't have Ollama, the workflows will use fallback content generation. 4. **Update URLs in Workflows (if needed)** - The workflows use `host.docker.internal` by default to reach services on the Docker host. - - GHOSTS API: `http://host.docker.internal:5000` + The workflows reach the GHOSTS API by its container name `ghosts-api`, which resolves + both under Docker Compose (same network) and under Aspire (host alias). Services that + run on the Docker host rather than as GHOSTS containers still use `host.docker.internal`. + - GHOSTS API: `http://ghosts-api:5000` - Socializer: `http://host.docker.internal:5555/` - Ollama: `http://host.docker.internal:11434/api/generate` diff --git a/docs/core/api.md b/docs/core/api.md index f13744752..ca9ef1134 100644 --- a/docs/core/api.md +++ b/docs/core/api.md @@ -69,10 +69,10 @@ Set these in a `.env` file alongside `docker-compose.yml` or directly in your co | Variable | Default | Description | |----------|---------|-------------| -| `N8N_API_URL` | `http://host.docker.internal:5678/api/v1/workflows` | n8n REST API endpoint (used by the API to list and validate workflows) | +| `N8N_API_URL` | `http://ghosts-n8n:5678/api/v1/workflows` | n8n REST API endpoint (used by the API to list and validate workflows) | | `N8N_API_KEY` | *(empty)* | n8n API key — **required** for workflow scheduling. Generate in n8n: Settings > API > Create API Key. | -| `WEB_API_URL` | `http://host.docker.internal:5000/api` | GHOSTS API URL served to the frontend container | -| `WEB_N8N_API_URL` | `http://host.docker.internal:5678` | n8n base URL served to the frontend container | +| `WEB_API_URL` | `http://localhost:5000/api` | GHOSTS API URL served to the frontend (must be reachable by the browser) | +| `WEB_N8N_API_URL` | `http://localhost:5678` | n8n base URL served to the frontend (must be reachable by the browser) | | `POSTGRES_PASSWORD` | set_me | PostgreSQL password. **Change this** for any non-local deployment. | ### appsettings.json (Advanced) diff --git a/src/Ghosts.Api/docker-compose.yml b/src/Ghosts.Api/docker-compose.yml index 1c44305cb..5ce7d5124 100644 --- a/src/Ghosts.Api/docker-compose.yml +++ b/src/Ghosts.Api/docker-compose.yml @@ -30,9 +30,9 @@ services: - "4200:80" environment: # API_URL must be reachable by the browser, not by Docker — use localhost since ports are mapped to the host - API_URL: ${WEB_API_URL:-http://host.docker.internal:5000/api} - N8N_API_URL: ${WEB_N8N_API_URL:-http://host.docker.internal:5678} - GRAFANA_URL: ${WEB_GRAFANA_URL:-http://host.docker.internal:3000} + API_URL: ${WEB_API_URL:-http://localhost:5000/api} + N8N_API_URL: ${WEB_N8N_API_URL:-http://localhost:5678} + GRAFANA_URL: ${WEB_GRAFANA_URL:-http://localhost:3000} ghosts-api: build: context: .. @@ -44,7 +44,7 @@ services: ports: - "5000:5000" environment: - N8N_API_URL: ${N8N_API_URL:-http://host.docker.internal:5678/api/v1/workflows} + N8N_API_URL: ${N8N_API_URL:-http://ghosts-n8n:5678/api/v1/workflows} N8N_API_KEY: ${N8N_API_KEY:-replace-me} restart: unless-stopped diff --git a/src/Ghosts.Pandora/src/appsettings.json b/src/Ghosts.Pandora/src/appsettings.json index 1af63f5f7..4996558cd 100644 --- a/src/Ghosts.Pandora/src/appsettings.json +++ b/src/Ghosts.Pandora/src/appsettings.json @@ -18,8 +18,8 @@ }, "ApplicationConfiguration": { "Ghosts": { - "ApiUrl": "http://host.docker.internal:5000/api", - "WorkflowsUrl": "http://host.docker.internal:5678" + "ApiUrl": "http://localhost:5000/api", + "WorkflowsUrl": "http://localhost:5678" }, "Mode": { "Type": "social", diff --git a/src/apphost/AppHost.cs b/src/apphost/AppHost.cs index 47de8fe12..8efc27b55 100644 --- a/src/apphost/AppHost.cs +++ b/src/apphost/AppHost.cs @@ -95,6 +95,10 @@ // points at the devcontainer, so map host.ollama -> Docker Desktop's host-gateway IP. // In the n8n UI, set the Ollama credential Base URL to http://host.ollama:11434. .WithContainerRuntimeArgs("--add-host", $"host.ollama:{ollamaHostIp}") + // Workflow JSONs call the API as http://ghosts-api:5000 so a single set of files works + // under both Compose (where ghosts-api is a service on the same network) and Aspire. + // Here the API is a devcontainer project, so alias ghosts-api to the host-gateway. + .WithContainerRuntimeArgs("--add-host", "ghosts-api:host-gateway") .WithBindMount("n8n_data", "/home/node/.n8n", isReadOnly: false) .WithBindMount("../../configuration/n8n-workflows", "/bootstrap/workflows", isReadOnly: true) .WithBindMount("../../configuration/n8n-bootstrap/scripts", "/bootstrap/scripts", isReadOnly: true) @@ -123,8 +127,9 @@ .WithBindMount("../../configuration/n8n-bootstrap/scripts", "/bootstrap/scripts", isReadOnly: true) .WaitFor(n8n); -// n8n workflows reach the API via host.docker.internal (configured in workflow nodes), -// not via Aspire service discovery, so no WithReference needed here. +// n8n workflows reach the API as http://ghosts-api:5000 (configured in workflow nodes), +// resolved via the ghosts-api host alias added to the n8n container above — not via +// Aspire service discovery, so no WithReference needed here. // Wire API to reach n8n for workflow execution — use host.docker.internal since // the API project runs inside a devcontainer and n8n exposes port 5678 on the host