FROM python:3.12-slim

# Install uv.
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/


WORKDIR /env_build

# Copy the application into the container.
COPY pyproject.toml uv.lock ./

RUN uv sync --frozen --no-cache

ENV PATH="/env_build/.venv/bin:$PATH"

# Install the application dependencies.
WORKDIR /app

# 更新索引并安装替代包
RUN apt-get update && apt-get install -y vim libxcb-shm0 libx11-xcb1 libx11-6 libxcb1 libxext6 libxrandr2 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libgtk-3-0t64 libpangocairo-1.0-0 libpango-1.0-0 libatk1.0-0t64 libcairo-gobject2 libcairo2 libgdk-pixbuf-2.0-0 libglib2.0-0t64 libxrender1 libasound2t64 libfreetype6 libfontconfig1 libdbus-1-3 libnss3 libgbm1 libatspi2.0-0 libcups2 libdrm2 libxkbcommon0
RUN playwright install


#CMD ["tail","-f","/dev/null"]
# Run the application.
CMD ["gunicorn", "main:app_server", \
     "-w", "4", \
     "-k", "uvicorn.workers.UvicornWorker", \
     "--bind", "0.0.0.0:80", \
     "--access-logfile", "-", \
     "--error-logfile", "-"]