# Base stage with system dependencies FROM python:3.11 # Thiết lập thư mục làm việc WORKDIR /code # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ wget \ gnupg \ git \ cmake \ pkg-config \ python3-dev \ libjpeg-dev \ libpng-dev \ && rm -rf /var/lib/apt/lists/* # Playwright system dependencies for Linux RUN apt-get update && apt-get install -y --no-install-recommends \ 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 \ libatspi2.0-0 \ && rm -rf /var/lib/apt/lists/* ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_DEFAULT_TIMEOUT=100 \ DEBIAN_FRONTEND=noninteractive # Cài đ?t các bi?n môi trư?ng ENV HOME=/code ENV XDG_CACHE_HOME=/code/.cache USER root ENV PATH="/home/user/.local/bin:$PATH" # T?o thư m?c cache và c?p quy?n RUN mkdir -p /code/.cache && chmod -R 777 /code # Cài đặt môi trường ảo Python # Sao chép mã nguồn COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt RUN pip install playwright RUN playwright install RUN playwright install-deps RUN playwright install chromium RUN pip install --upgrade --ignore-installed playwright RUN playwright install --with-deps chromium # Sao chép mã nguồn vào container COPY . . RUN pip install crawl4ai EXPOSE 7860 9222 # Khởi động ứng dụng CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]