File size: 989 Bytes
0f1d3e7
41dc236
0f1d3e7
 
 
 
41dc236
0f1d3e7
 
 
 
 
41dc236
0f1d3e7
9c9aae7
0f1d3e7
41dc236
b54d742
 
 
 
 
0f1d3e7
b54d742
0f1d3e7
41dc236
0f1d3e7
 
41dc236
0f1d3e7
b54d742
 
 
 
0f1d3e7
 
 
 
b54d742
9c9aae7
0f1d3e7
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
# Use the official Python image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# CONFIGURE PLAYWRIGHT
# Set a global path for browsers so both Root (builder) and User (runner) can find them
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH

# Install the necessary system dependencies and the Chromium browser
RUN playwright install-deps chromium
RUN playwright install chromium

# Copy Application Code
COPY . .

# Create and Switch to Non-Root User
RUN useradd -m -u 1000 user

# Ensure the user has permissions to access the browsers
RUN chmod -R 755 $PLAYWRIGHT_BROWSERS_PATH

USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# 6. Run the App
EXPOSE 7860
CMD ["python", "app.py"]