search_api / Dockerfile
eligapris's picture
Update Dockerfile
c53a149 verified
# Use Python 3.11 as the base image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
libglib2.0-0 \
libnss3 \
libnspr4 \
libdbus-1-3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libatspi2.0-0 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libpango-1.0-0 \
libcairo2 \
libasound2 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 appuser
# Copy pyproject.toml and install Python dependencies
COPY pyproject.toml .
RUN pip install -e .
# Copy the application code
COPY . .
# Install playwright
RUN playwright install
# Create directory for crawl4ai and set permissions
RUN mkdir -p /home/appuser/.crawl4ai && \
chown -R appuser:appuser /home/appuser/.crawl4ai && \
chown -R appuser:appuser /app
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV HOME=/home/appuser
# Switch to non-root user
USER appuser
# Expose the port the app runs on
EXPOSE 7860
# Command to run the FastAPI application with uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]