File size: 1,090 Bytes
d1fffc3
faca925
 
 
 
 
 
 
f114412
 
 
d1fffc3
 
 
 
 
 
 
faca925
f114412
d1fffc3
 
 
f114412
faca925
f114412
 
faca925
 
 
 
 
 
f114412
d1fffc3
faca925
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
FROM python:3.11-slim

# Set environment variables for GPU optimization
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV CUDA_VISIBLE_DEVICES=0

WORKDIR /code

# Install system dependencies efficiently
RUN apt-get update && apt-get install -y \
    --no-install-recommends \
    build-essential \
    wget \
    && rm -rf /var/lib/apt/lists/*

# Copy and install requirements first (for better caching)
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r /code/requirements.txt && \
    python -c "import nltk; nltk.download('punkt', quiet=True); nltk.download('stopwords', quiet=True)"

# Copy application files
COPY . .

# Create necessary directories with proper permissions
RUN mkdir -p /.cache .chroma /root/.cache/huggingface && \
    chmod 777 /.cache .chroma /root/.cache/huggingface

# Expose port
EXPOSE 7860

# Use exec form with optimized settings
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]