File size: 1,221 Bytes
fb63210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
FROM python:3.9-slim

# Install essential tools
RUN apt-get update && apt-get install -y \
    poppler-utils \
    pandoc \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy requirements file first for better caching
COPY requirements.txt ./

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt \
    && pip install python-multipart uvicorn fastapi pydantic requests jinja2

# Create directories and set permissions
RUN mkdir -p /app/frontend \
    && mkdir -p /tmp/.matplotlib \
    && chmod 777 /tmp/.matplotlib

# Set environment variables
ENV MPLCONFIGDIR=/tmp/.matplotlib
ENV PYTHONUNBUFFERED=1
# Uncomment and set your HF API key if needed
# ENV HF_API_KEY=your_huggingface_api_key

# Copy application code and static files
COPY backend_fastapi.py ./
COPY frontend ./frontend/

# Create requirements.txt if it doesn't exist yet
RUN if [ ! -f requirements.txt ]; then \
    echo "fastapi==0.103.1\nuvicorn==0.23.2\npython-multipart==0.0.6\nrequests==2.31.0\nJinja2==3.1.2\npydantic==2.4.2" > requirements.txt; \
    fi

# Expose port
EXPOSE 7860

# Start command
CMD ["uvicorn", "backend_fastapi:app", "--host", "0.0.0.0", "--port", "7860"]