Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker development local #37

Merged
merged 10 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 162 additions & 12 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,16 +1,166 @@
SECRET_KEY=
ALLOWED_HOSTS=
DEBUG=
DATABASE_URL=
ADMIN_URL=
DEFAULT_FROM_EMAIL=
# ------------------------------------------------------------------------------
# Django / KitchenAI Environment Variables
# ------------------------------------------------------------------------------

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_REGION_NAME=
# General Django settings
# ------------------------------------------------------------------------------
# Enable / disable debug mode (development = True, production = False)
DEBUG=False

# Whether KitchenAI is running locally and should not use background tasks
KITCHENAI_LOCAL=True

OPENAI_API_KEY=

# Allowed hosts (comma-separated)
# e.g., ALLOWED_HOSTS=localhost,127.0.0.1,example.com
ALLOWED_HOSTS=localhost

# Secret key for Django; required in production
# Generate a secure random string in production!
SECRET_KEY=django-insecure-change_me

# ------------------------------------------------------------------------------
# Database Settings
# ------------------------------------------------------------------------------
# Full database URL (e.g., Postgres, MySQL, or SQLite)
# Examples:
# Postgres: "postgres://USER:PASSWORD@HOST:PORT/NAME"
# SQLite: "sqlite:///relative/path/to/db.sqlite3"
# SQLite default: sqlite:///PROJECT_PATH/.kitchenai/db.sqlite3
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres

# Maximum connection age (in seconds) for persistent DB connections
# Often used in production to improve performance.
CONN_MAX_AGE=60

# ------------------------------------------------------------------------------
# Cache Settings
# ------------------------------------------------------------------------------
# If set, uses DiskCache for Django caching
# e.g.: CACHE_LOCATION=/tmp/django_cache
CACHE_LOCATION=
# Enable Redis caching (default: False)
KITCHENAI_REDIS_CACHE=True

# Redis connection URL for caching
# Format: redis://HOST:PORT/DB_NUMBER
REDIS_LOCATION=redis://127.0.0.1:6379/1

# ------------------------------------------------------------------------------
# AWS / S3 Settings (used if USE_S3=true)
# ------------------------------------------------------------------------------
# If using S3 or other object storage
USE_S3=True

# MinIO settings
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_STORAGE_BUCKET_NAME=kitchenai
AWS_S3_ENDPOINT_URL=http://localhost:9000 # Back to localhost
AWS_DEFAULT_REGION=us-east-1 # Can be any region
AWS_S3_VERIFY=False # Disable SSL verification for local dev
AWS_S3_ADDRESSING_STYLE=path # Use path-style addressing

# ------------------------------------------------------------------------------
# Email Settings
# ------------------------------------------------------------------------------
# Default 'from' email address
[email protected]

# Server email for error messages
[email protected]

# If using Resend for email sending
RESEND_API_KEY=

# ------------------------------------------------------------------------------
# Security & HTTPS Settings
# ------------------------------------------------------------------------------
# Enable Strict-Transport-Security in production (seconds)
# e.g., 120 for 2 minutes, or 604800 for 1 week
SECURE_HSTS_SECONDS=120

# ------------------------------------------------------------------------------
# Admin / URL Settings
# ------------------------------------------------------------------------------
# Path to Django admin
ADMIN_URL=kitchenai-admin/

# ------------------------------------------------------------------------------
# Logging Levels
# ------------------------------------------------------------------------------
# Set Django’s log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
DJANGO_LOG_LEVEL=INFO

# Set KitchenAI’s log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
KITCHENAI_LOG_LEVEL=DEBUG

# ------------------------------------------------------------------------------
# Sentry Settings
# ------------------------------------------------------------------------------
# Enable Sentry reporting
KITCHENAI_SENTRY=False

# DSN for Sentry (URL)
SENTRY_DSN=

DJANGO_SUPERUSER_EMAIL=
DJANGO_SUPERUSER_PASSWORD=
DJANGO_SUPERUSER_USERNAME=
# Environment for Sentry (development or production)
SENTRY_ENV=development

# ------------------------------------------------------------------------------
# Admin User Settings
# ------------------------------------------------------------------------------
# Default superuser credentials for initial setup
DJANGO_SUPERUSER_EMAIL=admin@localhost
DJANGO_SUPERUSER_PASSWORD=admin

# ------------------------------------------------------------------------------
# Simple RAG Bento Settings
# ------------------------------------------------------------------------------
# Model type for Simple RAG (litellm, ollama)
SIMPLE_RAG_MODEL_TYPE=litellm

# Model name for Simple RAG (gpt-4o, groq/llama-3.1-70b-versatile, gpt-4o-mini, llama2, mistral, mixtral)
SIMPLE_RAG_MODEL_NAME=gpt-4o

# Temperature for model responses (0.0 to 1.0)
SIMPLE_RAG_TEMPERATURE=0.7

# Vector store type (chroma)
SIMPLE_RAG_VECTOR_STORE=chroma

# Vector store endpoint
SIMPLE_RAG_VECTOR_STORE_ENDPOINT=localhost

# Chunk size for text splitting
SIMPLE_RAG_CHUNK_SIZE=1024


# ------------------------------------------------------------------------------
# KitchenAI Settings
# ------------------------------------------------------------------------------
# Which LLM provider to use (e.g., openai, anthropic, etc.)

#For FILES > 150MB defaults to LLAMA_CLOUD_API_KEY

LLAMA_CLOUD_API_KEY=

KITCHENAI_LLM_PROVIDER=openai

KITCHENAI_PLUGINS=deepeval_plugin

KITCHENAI_BENTO_BOXES=kitchenai_rag_simple_bento

# Default LLM model
KITCHENAI_LLM_MODEL=gpt-4o

# Enable built-in KitchenAI auth system
KITCHENAI_AUTH=false

# JWT secret for KitchenAI
KITCHENAI_JWT_SECRET=

# Theme selection from the predefined list
# e.g.: winter, dark, light, dracula, night, forest, cyberpunk, etc.
KITCHENAI_THEME=winter
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,16 @@ Notable project: [Falco Project](https://github.com/Tobi-De/falco). Thanks to th

KitchenAI collects **anonymous usage data** to improve the framework—no PII or sensitive data is collected.

> Your feedback and support shape KitchenAI. Let's build the future of AI development together!
> Your feedback and support shape KitchenAI. Let's build the future of AI development together!

## 🔧 **Quick Install**

You can quickly install KitchenAI Development Kit using this one-liner:


`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/epuerta9/kitchenai/main/scripts/install.sh)"`


You can also install the bundle with docker and docker-compose:

`curl -sSL https://raw.githubusercontent.com/epuerta9/kitchenai/main/scripts/install-bundle.sh | bash`
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@
from kitchenai.core.schema.rag import RAGConfigSchema
from pydantic import ValidationError
from kitchenai.core.schema.base import validate_bento_config
from kitchenai.core.types import EnvVars, ModelType, ModelName, VectorStore
from kitchenai.core.types import ModelType, ModelName, VectorStore
from kitchenai_rag_simple_bento.__version__ import __version__
from enum import Enum

class EnvVars(str, Enum):
MODEL_TYPE = "SIMPLE_RAG_MODEL_TYPE"
MODEL_NAME = "SIMPLE_RAG_MODEL_NAME"
TEMPERATURE = "SIMPLE_RAG_TEMPERATURE"
VECTOR_STORE = "SIMPLE_RAG_VECTOR_STORE"
VECTOR_STORE_ENDPOINT = "SIMPLE_RAG_VECTOR_STORE_ENDPOINT"
CHUNK_SIZE = "SIMPLE_RAG_CHUNK_SIZE"



def get_available_env_vars():
"""
Expand All @@ -24,6 +35,7 @@ def get_available_env_vars():
llm_name=os.environ.get(EnvVars.MODEL_NAME, ModelName.GPT4O),
temperature=float(os.environ.get(EnvVars.TEMPERATURE, "0.7")),
vector_store=os.environ.get(EnvVars.VECTOR_STORE, VectorStore.CHROMA),
vector_store_endpoint=os.environ.get(EnvVars.VECTOR_STORE_ENDPOINT, "chroma_db"),
chunk_size=int(os.environ.get(EnvVars.CHUNK_SIZE, "1024"))
)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.7"
__version__ = "0.1.10"
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@

config = get_available_env_vars()

print(config)



Settings.llm = LiteLLM(config.llm_name)

chroma_client = chromadb.PersistentClient(path="chroma_db")
def get_chroma_client():
#must do this to build build client at runtime
if config.vector_store_endpoint == "chroma_db":
chroma_client = chromadb.PersistentClient(path="chroma_db")
else:
chroma_client = chromadb.HttpClient(host=config.vector_store_endpoint, port=8000)
return chroma_client

chroma_client = get_chroma_client()
chroma_collection = chroma_client.get_or_create_collection("quickstart")


Expand Down
51 changes: 30 additions & 21 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ ENV PYTHONUNBUFFERED=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv" \
TAILWIND_CLI_PATH="/opt/tailwind" \
S6_KILL_GRACETIME=0 \
S6_OVERLAY_VERSION=3.1.6.2 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SYNC_DISKS=1 \
PYTHONPATH="/app"


ENV PATH="$VENV_PATH/bin:$PATH"

# Stage 2: Install dependencies & build static files
Expand All @@ -26,36 +21,50 @@ COPY ./requirements.txt ./
RUN pip install --upgrade pip uv \
&& python -m uv venv $VENV_PATH && uv pip install -r requirements.txt

# install plugins
RUN uv pip install "deepeval_plugin>=0.2.1"

#install bento boxes
RUN uv pip install "kitchenai_rag_simple_bento>=0.1.10"

# Install s6-overlay
RUN apt-get update && apt-get install -y xz-utils --no-install-recommends
RUN apt-get install build-essential nodejs npm -y
# Create base requirements file
RUN uv pip list > "$VENV_PATH/base-requirements.txt"

ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN mkdir /s6-install
RUN tar -C /s6-install -Jxpf /tmp/s6-overlay-noarch.tar.xz \
&& tar -C /s6-install -Jxpf /tmp/s6-overlay-x86_64.tar.xz
# Install build dependencies
RUN apt-get update && apt-get install -y build-essential nodejs npm --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Build static files
COPY . /app
WORKDIR /app

# Create necessary directories
RUN mkdir -p /app/kitchenai/static /app/kitchenai/staticfiles

RUN npm install -D daisyui
RUN python manage.py tailwind --skip-checks build \
&& python manage.py collectstatic --no-input --skip-checks --clear \
&& python manage.py compress
RUN python manage.py tailwind build
RUN python manage.py collectstatic --no-input --skip-checks --clear
RUN python manage.py compress

# Stage 3: Run service
FROM python-base as production

COPY --from=builder-base /s6-install /
# Install uv in the production stage
RUN pip install --upgrade pip uv

# Copy files from builder
COPY --from=builder-base $VENV_PATH $VENV_PATH
COPY --from=builder-base /app/kitchenai/staticfiles /app/kitchenai/staticfiles
COPY deploy/etc/s6-overlay /etc/s6-overlay
COPY --from=builder-base /app/kitchenai/static /app/kitchenai/static
COPY kitchenai /app/kitchenai
COPY manage.py /app/manage.py
RUN rm -r /app/kitchenai/static/

WORKDIR /app

EXPOSE 8001
ENTRYPOINT ["/init"]
# HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD curl -f http://0.0.0.0:8000/health

# Add entrypoint script
COPY deploy/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
58 changes: 58 additions & 0 deletions deploy/Dockerfile.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Stage 1: General enviroment
FROM python:3.12-slim-bookworm AS python-base
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv" \
TAILWIND_CLI_PATH="/opt/tailwind" \
PYTHONPATH="/app"

ENV PATH="$VENV_PATH/bin:$PATH"

# Stage 2: Install dependencies & build static files
FROM python-base as builder-base

# Install dependencies
WORKDIR $PYSETUP_PATH
COPY ./requirements.txt ./
RUN pip install --upgrade pip uv \
&& python -m uv venv $VENV_PATH && uv pip install -r requirements.txt

# Install build dependencies
RUN apt-get update && apt-get install -y build-essential nodejs npm --no-install-recommends

# Build static files
COPY . /app
WORKDIR /app

# Create necessary directories
RUN mkdir -p /app/kitchenai/static /app/kitchenai/staticfiles

RUN npm install -D daisyui
RUN python manage.py tailwind build
RUN python manage.py collectstatic --no-input --skip-checks --clear
RUN python manage.py compress

# Stage 3: Run service
FROM python-base as production

# Install uv in the production stage
RUN pip install --upgrade pip uv

COPY --from=builder-base $VENV_PATH $VENV_PATH
COPY --from=builder-base /app/kitchenai/staticfiles /app/kitchenai/staticfiles
COPY --from=builder-base /app/kitchenai/static /app/kitchenai/static
COPY kitchenai /app/kitchenai
COPY manage.py /app/manage.py

WORKDIR /app

EXPOSE 8001

# Add entrypoint script
COPY deploy/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
Loading
Loading