Spaces:
Sleeping
Sleeping
File size: 918 Bytes
1e7f554 91eab63 1e7f554 5a27bdd | 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 | # Use a lightweight Python base image
FROM python:3.10-slim
# Set up a working directory
WORKDIR /app
# In HuggingFace Spaces it's crucial to set up the correct user privileges
# Spaces require running as a non-root user with UID 1000
RUN useradd -m -u 1000 user && \
mkdir -p /app && \
chown -R user:user /app
USER user
# Set environmental variables
ENV PATH="/home/user/.local/bin:$PATH"
# Copy in the requirements file and install dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the actual Python script and .env if it exists
COPY --chown=user:user main.py .
# We don't forcibly COPY .env because users should use HF Secrets,
# but if it's there it won't break anything.
# The command to start our infinite loop script
# The -u flag is REQUIRED for Docker/HuggingFace so logs print immediately!
CMD ["python", "-u", "main.py", "--run"] |