# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
# you will also find guides on how best to write your Dockerfile | |
# Use official Python image | |
FROM python:3.9 | |
# Create a non-root user | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Set working directory | |
WORKDIR /app | |
# Copy and install dependencies | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy all project files | |
COPY --chown=user . /app | |
# Set environment variables for Flask | |
ENV FLASK_APP=src.app.app.py | |
ENV PYTHONPATH=/app/src:$PYTHONPATH | |
# Expose the Flask port | |
EXPOSE 7860 | |
# Run Flask | |
CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"] |