File size: 2,739 Bytes
f557cda
 
 
 
 
b6145cd
f557cda
 
 
 
4b4ef9e
f557cda
 
e535b57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b6145cd
 
4b4ef9e
 
e535b57
b6145cd
 
f557cda
 
4b4ef9e
 
 
e535b57
 
4b4ef9e
 
 
 
e535b57
4b4ef9e
 
 
 
b6145cd
f557cda
 
4b4ef9e
 
 
 
 
e535b57
b6145cd
 
 
 
 
e535b57
 
 
4b4ef9e
b6145cd
 
4b4ef9e
b6145cd
4b4ef9e
b6145cd
 
 
 
 
4b4ef9e
 
 
89b82c2
4b4ef9e
 
 
 
 
f557cda
4b4ef9e
 
 
 
 
 
b6145cd
4b4ef9e
 
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Base image with Python
FROM python:3.10-slim

# Set environment variable to prevent Python from writing .pyc files
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Set working directory inside the container
WORKDIR /project

# Install system dependencies for Playwright and general tools (your working version)
RUN apt-get update && apt-get install -y \
    build-essential \
    wget \
    gnupg \
    ca-certificates \
    fonts-liberation \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libatspi2.0-0 \
    libcups2 \
    libdbus-1-3 \
    libdrm2 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libxss1 \
    libxtst6 \
    libgbm1 \
    libxkbcommon0 \
    libxcursor1 \
    libxi6 \
    xvfb \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user for security BEFORE installing anything
RUN useradd --create-home --shell /bin/bash app

# Copy requirements first for better caching
COPY requirements.txt .
RUN chown app:app requirements.txt

# Switch to app user for all installations
USER app

# Set Playwright browsers path for app user
ENV PLAYWRIGHT_BROWSERS_PATH=/home/app/.cache/ms-playwright

# Install Python dependencies as app user
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -r requirements.txt

# Install Playwright browsers as app user using python -m
RUN python -m playwright install chromium

# Switch back to root to copy files and set permissions
USER root

# Create necessary directories for artifacts and temporary files
RUN mkdir -p /tmp/omirl_data
RUN mkdir -p /project/artifacts
RUN mkdir -p /project/logs

# Copy all project files into the container
COPY . .

# Set proper permissions for artifact directories and app user
RUN chmod 755 /tmp/omirl_data
RUN chmod 755 /project/artifacts
RUN chown -R app:app /project

# Set Playwright environment variables for headless operation (your working config)
ENV PLAYWRIGHT_HEADLESS=true

# Set Python path to include project root
ENV PYTHONPATH=/project

# LLM Router environment variables
ENV LLM_ROUTER_ENABLED=true
ENV DEFAULT_LLM_PROVIDER=gemini

# Switch back to app user for runtime
USER app

# Add the app user's local bin directory to PATH
ENV PATH="/home/app/.local/bin:$PATH"

# Health check (commented out since curl might not be available as app user)
# HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
#     CMD curl -f http://localhost:7860/_stcore/health || exit 1

# Expose the port that Streamlit will run on
EXPOSE 7860

# Command to run the Streamlit app
CMD ["streamlit", "run", "app/main.py", "--server.port=7860", "--server.address=0.0.0.0"]