File size: 2,012 Bytes
0eb5f56
 
 
 
 
 
 
9d5f27b
0eb5f56
 
 
 
9d5f27b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0eb5f56
 
 
9d5f27b
9a4271e
0eb5f56
 
 
9a4271e
0eb5f56
ca9a600
 
 
0eb5f56
7e5b577
8e46fec
 
 
7e5b577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0eb5f56
 
 
 
 
ca9a600
 
 
0eb5f56
 
8e46fec
0eb5f56
9d5f27b
0eb5f56
 
 
 
 
 
7e5b577
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
FROM python:3.10-slim

WORKDIR /app

# Create non-root user
RUN useradd -m -u 1000 user

# Install system dependencies
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    curl \
    libnss3 \
    libnspr4 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libdbus-1-3 \
    libxkbcommon0 \
    libx11-6 \
    libxcomposite1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libpango-1.0-0 \
    libcairo2 \
    libasound2 \
    libatspi2.0-0 \
    && pip install --upgrade pip \
    && pip install poetry

# Copy poetry configuration
COPY pyproject.toml poetry.lock ./

# Install Python dependencies using Poetry
RUN poetry config virtualenvs.create false \
    && poetry install --no-interaction --no-ansi --no-root

# Create directories and set permissions
RUN mkdir -p static templates screenshots /home/user/.cache && \
    chown -R user:user /app /home/user/.cache

# Set HOME for the browser
ENV HOME=/home/user \
    PYTHONPATH=/app

# Install additional Chrome dependencies
RUN apt-get update && apt-get install -y \
    fonts-noto-color-emoji \
    fonts-freefont-ttf \
    libharfbuzz-icu0 \
    # Chrome dependencies 
    libglib2.0-0 \
    unzip \
    xvfb

# Install Chrome - required for Helium
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Copy application code
COPY app /app/app
COPY templates /app/templates
COPY static /app/static

# Make sure all files are owned by user
RUN chown -R user:user /app

# Environment variables
ENV PORT=7860 \
    HOST=0.0.0.0

# Switch to non-root user for running the app
USER user

# Expose the port
EXPOSE 7860

# Start command
CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "7860"]