Merge pull request #1029 from DPS0340/master

Improve docker-compose.yml

- Do not expose dependencies on host internet
- Put all services on the same network
This commit is contained in:
sabaimran
2025-01-08 10:42:47 -08:00
committed by GitHub

View File

@@ -1,12 +1,13 @@
services: services:
database: database:
image: ankane/pgvector image: ankane/pgvector
ports: restart: always
- "5432:5432"
environment: environment:
POSTGRES_USER: postgres POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres POSTGRES_DB: postgres
networks:
- default
volumes: volumes:
- khoj_db:/var/lib/postgresql/data/ - khoj_db:/var/lib/postgresql/data/
healthcheck: healthcheck:
@@ -16,22 +17,25 @@ services:
retries: 5 retries: 5
sandbox: sandbox:
image: ghcr.io/khoj-ai/terrarium:latest image: ghcr.io/khoj-ai/terrarium:latest
ports: restart: always
- "8080:8080" networks:
- default
search: search:
image: docker.io/searxng/searxng:latest image: docker.io/searxng/searxng:latest
ports: restart: always
- "42113:8080" networks:
- default
volumes: volumes:
- khoj_search:/etc/searxng - khoj_search:/etc/searxng
environment: environment:
- SEARXNG_BASE_URL=http://localhost:42113/ - SEARXNG_BASE_URL=http://localhost:8080/
server: server:
depends_on: depends_on:
database: database:
condition: service_healthy 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. # 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 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. # 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: # build:
# context: . # context: .
@@ -42,6 +46,10 @@ services:
# as well as the port in the command section to match # as well as the port in the command section to match
- "42110:42110" - "42110:42110"
working_dir: /app working_dir: /app
networks:
- default
extra_hosts:
- "host.docker.internal:host-gateway"
volumes: volumes:
- khoj_config:/root/.khoj/ - khoj_config:/root/.khoj/
- khoj_models:/root/.cache/torch/sentence_transformers - khoj_models:/root/.cache/torch/sentence_transformers
@@ -58,9 +66,9 @@ services:
- KHOJ_ADMIN_EMAIL=username@example.com - KHOJ_ADMIN_EMAIL=username@example.com
- KHOJ_ADMIN_PASSWORD=password - KHOJ_ADMIN_PASSWORD=password
# Default URL of Terrarium, the Python sandbox used by Khoj to run code. Its container is specified above # 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 # 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. # 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. # Change URL to use with other OpenAI API compatible providers like VLLM, LMStudio etc.
# - OPENAI_API_BASE=http://host.docker.internal:11434/v1/ # - 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. # 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 command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode --non-interactive
volumes: volumes:
khoj_config: khoj_config:
khoj_db: khoj_db: