phishguard-api / Dockerfile
prashanth135's picture
Upload 38 files
bebe233 verified
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Create a non-root user for Hugging Face security
RUN useradd -m -u 1000 user
WORKDIR /home/user/app
# Install system dependencies required for Playwright and ML libs
RUN apt-get update && apt-get install -y --no-install-recommends \
wget curl libglib2.0-0 libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
libcups2 libdrm2 libdbus-1-3 libxcb1 libxkbcommon0 libx11-6 libxcomposite1 \
libxdamage1 libxext6 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 \
&& rm -rf /var/lib/apt/lists/*
# Install PyTorch CPU
RUN pip install --no-cache-dir torch==2.2.2 torchvision==0.17.2 --index-url https://download.pytorch.org/whl/cpu
# Copy requirements and install
COPY --chown=user requirements.txt .
RUN grep -v "torch==" requirements.txt | grep -v "torchvision==" > req_filtered.txt && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r req_filtered.txt
# Install Playwright browser
RUN playwright install chromium
# Copy project files
COPY --chown=user . .
# Create necessary directories and set permissions
RUN mkdir -p data logs bert_weights gnn cnn && \
chmod -R 777 data logs bert_weights
# Expose the Hugging Face default port
EXPOSE 7860
# Command to run on start (Port 7860 is required for HF)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]