File size: 1,051 Bytes
2c78cf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc8152f
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
38
# Use Python 3.13 slim as the base image
FROM python:3.13-slim

# Install git and other necessary packages
RUN apt-get update && apt-get install -y \
    git \
    && rm -rf /var/lib/apt/lists/*

# Expose the secret GROQ_API_KEY at buildtime and use its value as git remote URL
RUN --mount=type=secret,id=GROQ_API_KEY,mode=0444,required=true \
 git init && \
 git remote add origin $(cat /run/secrets/GROQ_API_KEY)

# Set the working directory
WORKDIR /app

# Create cache directory with proper permissions
RUN mkdir -p /.cache && chmod 777 /.cache

# Set environment variable for transformers cache
ENV TRANSFORMERS_CACHE=/.cache/transformers
ENV HF_HOME=/.cache/huggingface

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Download the BGE embedding model
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-small-en-v1.5')"

# Copy app folder
COPY app/ .

# Expose Gradio's default port
EXPOSE 7860

# Run the app
CMD ["python", "app.py"]