File size: 1,250 Bytes
f92d24c
 
1b4bba1
f92d24c
 
1b4bba1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f92d24c
 
 
1b4bba1
f92d24c
 
1b4bba1
 
 
 
f92d24c
 
 
 
 
 
 
 
1b4bba1
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
# Use the official Python 3.12 slim image
FROM python:3.12-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

# Create cache directories with proper permissions
RUN mkdir -p /tmp/huggingface_cache /tmp/transformers_cache /tmp/datasets_cache && \
    chmod -R 777 /tmp/huggingface_cache /tmp/transformers_cache /tmp/datasets_cache

# Set environment variables for cache directories
ENV HF_HOME=/tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
ENV HF_DATASETS_CACHE=/tmp/datasets_cache
ENV PYTHONUNBUFFERED=1
ENV PORT=7860

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

# Copy all application files
COPY . .

# Expose the port
EXPOSE 7860

# Run the FastAPI app with Uvicorn on port 7860 (required by HF Spaces)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]

# docker build -t precollegefastapi .
# docker images
# docker ps
# docker run --env-file .env -p 8080:8080 precollegefastapi 
# docker tag precollegefastapi asura0575/precollegefastapi:latest
# docker push asura0575/precollegefastapi