Spaces:
Sleeping

tiny / Dockerfile
Beikx's picture
Upload Dockerfile
1658e5d verified
Raw History Blame Contribute Delete
871 Bytes
# Use a lightweight Python image
FROM python:3.9-slim
# Set environment variables
# PYTHONUNBUFFERED: Forces stdout/stderr to be flushed immediately (critical for logs)
# PYTHONDONTWRITEBYTECODE: Prevents Python from writing .pyc files
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=7860
# Install pngquant, jpegoptim and zip
RUN apt-get update && \
apt-get install -y pngquant jpegoptim zip && \
rm -rf /var/lib/apt/lists/*
# Create a non-root user (Security Best Practice for HF Spaces)
RUN useradd -m -u 1000 user
# Set working directory
WORKDIR /app
# Copy application files with correct ownership
COPY --chown=user:user web_app.py .
COPY --chown=user:user index.html .
# Switch to the non-root user
USER user
# Expose the port (Hugging Face Spaces defaults to 7860)
EXPOSE 7860
# Start the application
CMD ["python", "web_app.py"]