File size: 992 Bytes
8753236
4ee91a0
8753236
 
 
 
 
6fb7326
 
8753236
 
57d02cb
8753236
4ee91a0
 
 
 
 
 
 
8753236
 
4ee91a0
6fb7326
 
4ee91a0
 
 
 
57d02cb
8753236
4ee91a0
ccd6e6d
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
# Use an official Python image
FROM python:3.9-slim

# Set environment variables for cache location
ENV HF_HOME="/app/cache"
ENV TRANSFORMERS_CACHE="/app/cache"

# Create the cache directory and set permissions
RUN mkdir -p /app/cache && chmod -R 777 /app/cache

# Set working directory
WORKDIR /app

# Copy the requirements file first (to leverage Docker's layer caching)
COPY requirements.txt /app/

# Install dependencies from requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . /app

# Ensure all files are accessible
RUN chmod -R 777 /app

# Pre-download the model (to avoid runtime downloading issues)
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/clip-ViT-B-32-multilingual-v1')" && chmod -R 777 /app/cache

# Expose FastAPI port
EXPOSE 7860

# Start FastAPI application
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]