Lead-Scoring-Model / Dockerfile
adeyemi001's picture
Create Dockerfile
ddbada2 verified
Raw
History Blame Contribute Delete
757 Bytes
# HuggingFace Spaces — Flask Purchase Predictor
FROM python:3.10-slim
# HF Spaces runs as a non-root user; create one to match
RUN useradd -m -u 1000 appuser
WORKDIR /app
# Install dependencies first (layer cache)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY app.py .
COPY templates/ templates/
# Copy your trained model — ensure the file is in the same folder
# before building the image
COPY random_over_sampling_model.pkl .
# Switch to non-root user (required by HuggingFace Spaces)
USER appuser
# HuggingFace Spaces expects port 7860
EXPOSE 7860
ENV PORT=7860
# Use gunicorn for production
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]