anky2002 commited on
Commit
c8e9dda
·
verified ·
1 Parent(s): 6dd7657

fix: Update Dockerfile to install fpdf2 + weasyprint deps, playwright setup

Browse files
Files changed (1) hide show
  1. backend/Dockerfile +18 -11
backend/Dockerfile CHANGED
@@ -2,31 +2,38 @@ FROM python:3.12-slim
2
 
3
  WORKDIR /app
4
 
5
- # System deps
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  build-essential \
8
  curl \
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Install uv - ultrafast Python package manager
12
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
13
 
14
- # Copy project files for dependency resolution
15
  COPY pyproject.toml uv.lock* ./
16
 
17
- # Install dependencies with uv (much faster than pip)
18
- RUN uv sync --frozen --no-dev --no-install-project
19
 
20
- # Install playwright browsers for scraping
21
- RUN uv run playwright install chromium --with-deps
22
 
23
- # Copy application code
 
 
 
24
  COPY . .
25
 
26
- # Install the project itself
27
- RUN uv sync --frozen --no-dev
28
 
29
  EXPOSE 8000
30
 
31
- # Use uv run to ensure correct venv
32
  CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
2
 
3
  WORKDIR /app
4
 
5
+ # System deps (including WeasyPrint dependencies)
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  build-essential \
8
  curl \
9
+ libpango-1.0-0 \
10
+ libpangocairo-1.0-0 \
11
+ libgdk-pixbuf2.0-0 \
12
+ libffi-dev \
13
+ libcairo2 \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Install uv
17
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
18
 
19
+ # Copy project files
20
  COPY pyproject.toml uv.lock* ./
21
 
22
+ # Install dependencies
23
+ RUN uv sync --frozen --no-dev --no-install-project || uv sync --no-dev --no-install-project
24
 
25
+ # Install extra PDF deps (fpdf2 for fallback, weasyprint for quality)
26
+ RUN uv pip install --system fpdf2 weasyprint 2>/dev/null || uv pip install --system fpdf2
27
 
28
+ # Install playwright browsers
29
+ RUN uv run playwright install chromium --with-deps 2>/dev/null || true
30
+
31
+ # Copy app
32
  COPY . .
33
 
34
+ # Install project
35
+ RUN uv sync --frozen --no-dev 2>/dev/null || uv sync --no-dev
36
 
37
  EXPOSE 8000
38
 
 
39
  CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]