ping / Dockerfile
Alvin3y1's picture
Create Dockerfile
122c84c verified
raw
history blame contribute delete
708 Bytes
# Use the official Python 3.9 image
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Create a non-root user with ID 1000 (Required for HF Spaces security)
RUN useradd -m -u 1000 user
# Set the working directory
WORKDIR /app
# Install dependencies (Doing this first leverages Docker cache)
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code with correct permissions
COPY --chown=user:user . .
# Switch to the non-root user
USER user
# Expose the port Hugging Face expects
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]