Spaces:
Sleeping
Sleeping
File size: 924 Bytes
668f6d9 1ee09b9 668f6d9 |
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 |
FROM python:3.9-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=7860 \
TRANSFORMERS_CACHE=/tmp/huggingface
# Set the working directory
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create cache directory with proper permissions
RUN mkdir -p /tmp/huggingface && chmod 777 /tmp/huggingface
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application
COPY ./app /code/app
# Make port 7860 available
EXPOSE 7860
# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos "" appuser && \
chown -R appuser:appuser /code /tmp/huggingface
USER appuser
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |