From b91a5528acbdb9b1570c3a4a459f2dbc895960bc Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:59:47 +0100 Subject: [PATCH] feat: Adds docker with Ollama support --- docker-compose.ollama.yml | 91 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 docker-compose.ollama.yml diff --git a/docker-compose.ollama.yml b/docker-compose.ollama.yml new file mode 100644 index 0000000..82ffec3 --- /dev/null +++ b/docker-compose.ollama.yml @@ -0,0 +1,91 @@ +version: '3.7' + +services: + backend: + build: . + command: uvicorn app.main:app --reload --host 0.0.0.0 --port 8050 --proxy-headers + volumes: + - ./src/:/app/ + ports: + - "8050:8050" + environment: + - SUPERADMIN_GH_PAT=${SUPERADMIN_GH_PAT} + - SUPERADMIN_PWD=${SUPERADMIN_PWD} + - GH_OAUTH_ID=${GH_OAUTH_ID} + - GH_OAUTH_SECRET=${GH_OAUTH_SECRET} + - POSTGRES_URL=postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db/${POSTGRES_DB} + - OPENAI_API_KEY=${OPENAI_API_KEY} + - SECRET_KEY=${SECRET_KEY} + - SENTRY_DSN=${SENTRY_DSN} + - SERVER_NAME=${SERVER_NAME} + - POSTHOG_KEY=${POSTHOG_KEY} + - SLACK_API_TOKEN=${SLACK_API_TOKEN} + - SLACK_CHANNEL=${SLACK_CHANNEL} + - OLLAMA_ENDPOINT=http://ollama:11434 + - OLLAMA_MODEL=${OLLAMA_MODEL} + - SUPPORT_EMAIL=${SUPPORT_EMAIL} + - DEBUG=true + depends_on: + db: + condition: service_healthy + ollama: + condition: service_healthy + + ollama: + image: ollama/ollama:latest + command: serve && ollama pull ${OLLAMA_MODEL} + volumes: + - "$HOME/.ollama:/root/.ollama" + expose: + - 11434 + healthcheck: + test: ["CMD-SHELL", "ollama list | grep -q '${OLLAMA_MODEL}'"] + interval: 10s + timeout: 3s + retries: 3 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + + # ollama-webui: + # image: ghcr.io/ollama-webui/ollama-webui:main + # container_name: ollama-webui + # depends_on: + # - ollama + # # Uncomment below for WIP: Auth support + # # - ollama-webui-db + # ports: + # - 3000:8080 + # environment: + # - "OLLAMA_API_BASE_URL=http://ollama:11434/api" + # # Uncomment below for WIP: Auth support + # # - "WEBUI_AUTH=TRUE" + # # - "WEBUI_DB_URL=mongodb://root:example@ollama-webui-db:27017/" + # # - "WEBUI_JWT_SECRET_KEY=SECRET_KEY" + # # extra_hosts: + # # - host.docker.internal:host-gateway + # # restart: unless-stopped + + db: + image: postgres:15-alpine + volumes: + - postgres_data:/var/lib/postgresql/data/ + expose: + - 5432 + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + healthcheck: + test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'"] + interval: 10s + timeout: 3s + retries: 3 + +volumes: + postgres_data: + ollama: