euler314 commited on
Commit
3607227
·
verified ·
1 Parent(s): 23a9c5d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +79 -53
Dockerfile CHANGED
@@ -1,66 +1,92 @@
1
- # Use Ubuntu 20.04 as the base image
2
- FROM ubuntu:20.04
3
 
4
- # Prevent interactive prompts during package installation
 
 
 
5
  ENV DEBIAN_FRONTEND=noninteractive
 
 
 
 
 
6
 
7
- # Update packages and install system dependencies (including Python 3.10)
8
- RUN apt-get update && apt-get install -y \
9
- software-properties-common \
10
- && add-apt-repository ppa:deadsnakes/ppa \
11
- && apt-get update && apt-get install -y \
12
- python3.10 \
13
- python3.10-venv \
14
- python3.10-dev \
15
- git \
16
- git-lfs \
17
- ffmpeg \
18
- libsm6 \
19
- libxext6 \
20
- cmake \
21
- rsync \
22
- libgl1-mesa-glx \
23
- curl \
24
- ca-certificates \
25
- && rm -rf /var/lib/apt/lists/* \
26
- && git lfs install
27
 
28
- # Create a non-root user and switch to it
29
- RUN useradd -m -u 1000 user
30
- USER user
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- # Set working directory
33
- WORKDIR /home/user/app
 
 
 
 
 
 
 
 
34
 
35
- # Create and activate a virtual environment
36
- RUN python3.10 -m venv venv
37
- ENV PATH="/home/user/app/venv/bin:${PATH}"
38
 
39
- # Upgrade pip and install common Python packages
40
- RUN pip install --upgrade pip && \
41
- pip install --no-cache-dir \
42
- datasets \
43
- "huggingface-hub>=0.19" \
44
- "hf-transfer>=0.1.4" \
45
- "protobuf<4" \
46
- "click<8.1" \
47
- "pydantic~=1.0"
48
 
49
- # Set environment variable to force Playwright to install browsers locally
50
- ENV PLAYWRIGHT_BROWSERS_PATH=0
51
 
52
- # Copy the requirements file and install project dependencies
53
- COPY --chown=user:user requirements.txt .
54
- RUN pip install --no-cache-dir -r requirements.txt
 
 
55
 
56
- # Copy the rest of your application code
57
- COPY --chown=user:user . .
58
 
59
- # Install Playwright browsers (now installs in a local folder)
60
- RUN python -m playwright install chromium
 
 
61
 
62
- # Expose your app's port (for example, 8501 for Streamlit)
63
- EXPOSE 8501
64
 
65
- # Set the default command to run your app
66
- CMD ["python", "app.py"]
 
1
+ FROM ubuntu:22.04
 
2
 
3
+ USER root
4
+
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
  ENV DEBIAN_FRONTEND=noninteractive
8
+ ENV PIP_ROOT_USER_ACTION=ignore
9
+ ENV HOME=/home/user
10
+ ENV PLAYWRIGHT_BROWSERS_PATH=${HOME}/.cache/ms-playwright
11
+ ENV LD_LIBRARY_PATH=/usr/lib/playwright:/usr/lib/x86_64-linux-gnu
12
+ ENV GRADIO_NODE_PORT=disabled
13
 
14
+ RUN useradd -m -d /home/user user && \
15
+ mkdir -p ${HOME}/.cache/ms-playwright && \
16
+ mkdir -p /usr/lib/playwright && \
17
+ chown -R user:user ${HOME}/.cache && \
18
+ chmod -R 755 ${HOME}/.cache
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ RUN apt-get update && \
21
+ apt-get install -y --no-install-recommends \
22
+ python3.11 \
23
+ python3-pip \
24
+ python3.11-dev \
25
+ wget \
26
+ unzip \
27
+ ca-certificates \
28
+ libnss3 \
29
+ libnss3-tools \
30
+ libnspr4 \
31
+ libatk1.0-0 \
32
+ libatk-bridge2.0-0 \
33
+ libatspi2.0-0 \
34
+ libcups2 \
35
+ libxcomposite1 \
36
+ libxdamage1 \
37
+ libxrandr2 \
38
+ libxkbcommon0 \
39
+ libx11-xcb1 \
40
+ libxcursor1 \
41
+ libxi6 \
42
+ libxss1 \
43
+ libxtst6 \
44
+ libasound2 \
45
+ libx11-6 \
46
+ libxcb1 \
47
+ libxext6 \
48
+ libxfixes3 \
49
+ libxrender1 \
50
+ libdbus-1-3 \
51
+ libdrm2 \
52
+ libpango-1.0-0 \
53
+ fonts-liberation \
54
+ fonts-noto-color-emoji \
55
+ gcc && \
56
+ apt-get clean && \
57
+ rm -rf /var/lib/apt/lists/*
58
 
59
+ RUN ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/playwright/ && \
60
+ ln -s /usr/lib/x86_64-linux-gnu/libnssutil3.so /usr/lib/playwright/ && \
61
+ ln -s /usr/lib/x86_64-linux-gnu/libsmime3.so /usr/lib/playwright/ && \
62
+ ln -s /usr/lib/x86_64-linux-gnu/libnspr4.so /usr/lib/playwright/ && \
63
+ ln -s /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 /usr/lib/playwright/ && \
64
+ ln -s /usr/lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0 /usr/lib/playwright/ && \
65
+ ln -s /usr/lib/x86_64-linux-gnu/libcups.so.2 /usr/lib/playwright/ && \
66
+ ln -s /usr/lib/x86_64-linux-gnu/libatspi.so.0 /usr/lib/playwright/ && \
67
+ ln -s /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 /usr/lib/playwright/ && \
68
+ ln -s /usr/lib/x86_64-linux-gnu/libXdamage.so.1 /usr/lib/playwright/
69
 
70
+ WORKDIR /app
 
 
71
 
72
+ COPY requirements.txt ./
73
+ RUN pip3 install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
74
 
75
+ RUN PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pip3 install playwright==1.30.0
 
76
 
77
+ RUN cd ${HOME}/.cache/ms-playwright && \
78
+ wget -q https://playwright.azureedge.net/builds/chromium/1045/chromium-linux.zip && \
79
+ unzip chromium-linux.zip && \
80
+ rm chromium-linux.zip && \
81
+ chmod -R 755 ${HOME}/.cache/ms-playwright
82
 
83
+ COPY . .
 
84
 
85
+ RUN chown -R user:user /app && \
86
+ chmod -R 755 /app && \
87
+ chmod -R 755 ${HOME}/.cache/ms-playwright && \
88
+ chmod -R 755 /usr/lib/playwright
89
 
90
+ USER user
 
91
 
92
+ CMD ["python3", "app.py"]