mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +00:00
Update default docker compose configuration with Khoj local mode
This commit is contained in:
@@ -10,7 +10,15 @@ services:
|
|||||||
POSTGRES_DB: postgres
|
POSTGRES_DB: postgres
|
||||||
volumes:
|
volumes:
|
||||||
- khoj_db:/var/lib/postgresql/data/
|
- khoj_db:/var/lib/postgresql/data/
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
server:
|
server:
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
# Use the following line to use the latest version of khoj. Otherwise, it will build from source.
|
# Use the following line to use the latest version of khoj. Otherwise, it will build from source.
|
||||||
image: ghcr.io/khoj-ai/khoj:latest
|
image: ghcr.io/khoj-ai/khoj:latest
|
||||||
# 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 offiicial 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 offiicial image.
|
||||||
@@ -47,9 +55,11 @@ services:
|
|||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD=postgres
|
||||||
- POSTGRES_HOST=database
|
- POSTGRES_HOST=database
|
||||||
- POSTGRES_PORT=5432
|
- POSTGRES_PORT=5432
|
||||||
- GOOGLE_CLIENT_SECRET=bar
|
- KHOJ_DJANGO_SECRET_KEY=secret
|
||||||
- GOOGLE_CLIENT_ID=foo
|
- KHOJ_DEBUG=True
|
||||||
command: --host="0.0.0.0" --port=42110 -vv
|
- ADMIN_EMAIL=username@example.com
|
||||||
|
- ADMIN_PASSWORD=password
|
||||||
|
command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from database.models import (
|
from database.models import (
|
||||||
KhojUser,
|
KhojUser,
|
||||||
@@ -17,9 +18,11 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def initialization():
|
def initialization():
|
||||||
def _create_admin_user():
|
def _create_admin_user():
|
||||||
logger.info("👩✈️ Setting up admin user")
|
logger.info(
|
||||||
email_addr = input("Email Address: ")
|
"👩✈️ Setting up admin user. These credentials will allow you to configure your server at /django/admin."
|
||||||
password = input("Password: ")
|
)
|
||||||
|
email_addr = os.getenv("ADMIN_EMAIL") or input("Email: ")
|
||||||
|
password = os.getenv("ADMIN_PASSWORD") or input("Password: ")
|
||||||
admin_user = KhojUser.objects.create_superuser(email=email_addr, username=email_addr, password=password)
|
admin_user = KhojUser.objects.create_superuser(email=email_addr, username=email_addr, password=password)
|
||||||
logger.info(f"👩✈️ Created admin user: {admin_user.email}")
|
logger.info(f"👩✈️ Created admin user: {admin_user.email}")
|
||||||
|
|
||||||
@@ -27,6 +30,15 @@ def initialization():
|
|||||||
logger.info(
|
logger.info(
|
||||||
"🗣️ Configure chat models available to your server. You can always update these at /django/admin using the credentials of your admin account"
|
"🗣️ Configure chat models available to your server. You can always update these at /django/admin using the credentials of your admin account"
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
# Some environments don't support interactive input. We catch the exception and return if that's the case. The admin can still configure their settings from the admin page.
|
||||||
|
input()
|
||||||
|
except EOFError:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
import gpt4all
|
||||||
|
|
||||||
use_offline_model = input("Use offline chat model? (y/n): ")
|
use_offline_model = input("Use offline chat model? (y/n): ")
|
||||||
if use_offline_model == "y":
|
if use_offline_model == "y":
|
||||||
logger.info("🗣️ Setting up offline chat model")
|
logger.info("🗣️ Setting up offline chat model")
|
||||||
@@ -48,6 +60,8 @@ def initialization():
|
|||||||
max_prompt_size=max_tokens,
|
max_prompt_size=max_tokens,
|
||||||
tokenizer=tokenizer,
|
tokenizer=tokenizer,
|
||||||
)
|
)
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
logger.warning("Offline models are not supported on this device.")
|
||||||
|
|
||||||
use_openai_model = input("Use OpenAI chat model? (y/n): ")
|
use_openai_model = input("Use OpenAI chat model? (y/n): ")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user