Spaces:
Sleeping
Sleeping
File size: 1,078 Bytes
e895030 | 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 | # Use an official lightweight Python base image
FROM python:3.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Set working directory
WORKDIR /code
# Install system dependencies if any are needed
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install dependencies
COPY requirements.txt /code/
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Create directories and files with write access for Hugging Face non-root user (UID 1000)
RUN mkdir -p /code/logs && \
touch /code/emails.db && \
chmod -R 777 /code
# Copy the rest of the application code
COPY . /code/
# Set ownership of the application directory to the non-root user (UID 1000)
RUN chown -R 1000:1000 /code
# Switch to the non-root user (Hugging Face standard)
USER 1000
# Expose port 7860 (Hugging Face standard port)
EXPOSE 7860
# Command to run the FastAPI app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|