File size: 1,457 Bytes
7190baf
 
95f7828
 
203c659
 
 
af04fc7
 
 
9b37f2b
95f7828
 
 
 
 
 
 
 
 
 
 
 
 
 
9b37f2b
 
 
 
 
 
 
 
 
 
5b299ea
 
95f7828
 
9b37f2b
95f7828
 
fe8fc9d
 
95f7828
9b37f2b
af04fc7
95f7828
9b37f2b
7190baf
9b37f2b
245aff6
af04fc7
95f7828
9b37f2b
af04fc7
9b37f2b
 
 
95f7828
203c659
af04fc7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM python:3.12

WORKDIR /app

# Set Playwright's cache directory to a writable location
ENV PLAYWRIGHT_BROWSERS_PATH=/app/playwright-browsers

# Create the Playwright browser cache directory and set correct permissions
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH && chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH

# Install required system dependencies for Playwright
RUN apt-get update && apt-get install -y \
    libnss3 \
    libnspr4 \
    libdbus-1-3 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libatspi2.0-0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libxkbcommon0 \
    libasound2 \
    libcups2 \
    libglib2.0-0 \
    libxshmfence1 \
    libgdk-pixbuf2.0-0 \
    libegl1 \
    libopus0 \
    libwoff1 \
    libharfbuzz-icu0 \
    libhyphen0 \
    libevent-2.1-7 \
    libxcursor1 \
    libgtk-3-0 \
    && rm -rf /var/lib/apt/lists/*

# Install Poetry
RUN pip install --no-cache-dir poetry

# Set Poetry virtualenvs to be inside the project
ENV POETRY_VIRTUALENVS_IN_PROJECT=true

# Copy dependency files first (for better caching)
COPY pyproject.toml poetry.lock ./ 

# Install dependencies
RUN poetry install --no-root 

# Install Playwright within Poetry environment
RUN poetry run playwright install --with-deps chromium

# Copy the rest of the application
COPY . . 

# Expose port
EXPOSE 7860

# Run application
CMD ["poetry", "run", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]