# Use an official Python runtime as a parent image
FROM nvidia/cuda:11.7.0-runtime-ubuntu20.04

# Set environment variables
ENV EVAL_PORT=8000 \
    MODEL_NAME=gpt-4 \
    CELERY_BROKER_URL=redis://localhost:6379 \
    SERVER=http://localhost:${EVAL_PORT} \
    USE_GPU=True \
    PLAYGROUND_DIR=playground \
    LOG_LEVEL=INFO \
    BOT_NAME=Orca \
    # You will need to set these environment variables to your actual keys in production
    OPENAI_API_KEY=your_openai_api_key \
    WINEDB_HOST=your_winedb_host \
    WINEDB_PASSWORD=your_winedb_password \
    BING_SEARCH_URL=your_bing_search_url \
    BING_SUBSCRIPTION_KEY=your_bing_subscription_key \
    SERPAPI_API_KEY=your_serpapi_api_key \
    REDIS_HOST=your_redis_host \
    REDIS_PORT=your_redis_port

# Set work directory
WORKDIR /usr/src/app

# Install system dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-get install -y python3.10 python3-pip curl && \
    apt-get install -y nodejs npm

# Add requirements file
COPY requirements.txt ./

# Install any needed packages specified in requirements.txt
RUN python3.10 -m pip install --upgrade pip && \
    python3.10 -m pip install --no-cache-dir -r requirements.txt

# Bundle app source
COPY . .

# Expose port
EXPOSE ${EVAL_PORT}

# Run the application
CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8000"]