Spaces:
Sleeping
Sleeping
File size: 1,054 Bytes
1aab264 |
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 |
# Use Python 3.9
FROM python:3.9
# Set working directory to /code
WORKDIR /code
# Copy the requirements file
COPY ./requirements.txt /code/requirements.txt
# Install system dependencies (needed for OpenCV/EasyOCR and building packages)
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Install dependencies
# We use the CPU-only version of PyTorch to reduce image size
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /code/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
# Copy the application code
COPY ./main.py /code/main.py
# Create a directory for cache (needed for Transformers/Hugging Face models)
# and give it correct permissions
RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
ENV TRANSFORMERS_CACHE=/code/.cache
# Expose port 7860 (Hugging Face default)
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|