From a5c7315874907cdcda667bce98b0638378007fc7 Mon Sep 17 00:00:00 2001 From: Jiho Lee Date: Sun, 5 Jan 2025 15:17:50 +0900 Subject: [PATCH] feat: Improve docker-compose.yml - Remove host port mappings on dependencies - Add 'restart: always' - Add default network for lookup by docker dns --- docker-compose.yml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3a8c90ec..615dba8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,13 @@ services: database: image: ankane/pgvector - ports: - - "5432:5432" + restart: always environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: postgres + networks: + - default volumes: - khoj_db:/var/lib/postgresql/data/ healthcheck: @@ -16,22 +17,25 @@ services: retries: 5 sandbox: image: ghcr.io/khoj-ai/terrarium:latest - ports: - - "8080:8080" + restart: always + networks: + - default search: image: docker.io/searxng/searxng:latest - ports: - - "42113:8080" + restart: always + networks: + - default volumes: - khoj_search:/etc/searxng environment: - - SEARXNG_BASE_URL=http://localhost:42113/ + - SEARXNG_BASE_URL=http://0.0.0.0:8080/ server: depends_on: database: condition: service_healthy # Use the following line to use the latest version of khoj. Otherwise, it will build from source. Set this to ghcr.io/khoj-ai/khoj-cloud:latest if you want to use the prod image. image: ghcr.io/khoj-ai/khoj:latest + restart: always # Uncomment the following line to build from source. This will take a few minutes. Comment the next two lines out if you want to use the official image. # build: # context: . @@ -42,6 +46,10 @@ services: # as well as the port in the command section to match - "42110:42110" working_dir: /app + networks: + - default + extra_hosts: + - "host.docker.internal:host-gateway" volumes: - khoj_config:/root/.khoj/ - khoj_models:/root/.cache/torch/sentence_transformers @@ -58,9 +66,9 @@ services: - KHOJ_ADMIN_EMAIL=username@example.com - KHOJ_ADMIN_PASSWORD=password # Default URL of Terrarium, the Python sandbox used by Khoj to run code. Its container is specified above - - KHOJ_TERRARIUM_URL=http://host.docker.internal:8080 + - KHOJ_TERRARIUM_URL=http://sandbox:8080 # Default URL of SearxNG, the default web search engine used by Khoj. Its container is specified above - - KHOJ_SEARXNG_URL=http://host.docker.internal:42113 + - KHOJ_SEARXNG_URL=http://search:8080 # Uncomment line below to use with Ollama running on your local machine at localhost:11434. # Change URL to use with other OpenAI API compatible providers like VLLM, LMStudio etc. # - OPENAI_API_BASE=http://host.docker.internal:11434/v1/ @@ -98,7 +106,6 @@ services: # Comment out this line when you're using the official ghcr.io/khoj-ai/khoj-cloud:latest prod image. command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode --non-interactive - volumes: khoj_config: khoj_db: