nnilayy commited on
Commit
fd3bcc5
·
1 Parent(s): 6a06eb9

Update logic

Browse files
Files changed (2) hide show
  1. Dockerfile +10 -10
  2. entrypoint.sh +3 -7
Dockerfile CHANGED
@@ -4,10 +4,10 @@ FROM ubuntu:22.04
4
  # Set up environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive \
6
  PYTHONUNBUFFERED=1 \
7
- PATH="/home/user/.local/bin:$PATH" \
8
  XDG_RUNTIME_DIR=/tmp/runtime-user
9
 
10
- # Install system dependencies including Python
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  ca-certificates \
13
  curl \
@@ -24,10 +24,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
24
  libgtk-3-0 \
25
  libgbm-dev \
26
  libxshmfence1 \
27
- python3 \
28
- python3-pip \
29
- python3-dev \
30
  && rm -rf /var/lib/apt/lists/* \
 
31
  && ln -s /usr/bin/python3 /usr/bin/python
32
 
33
  # Install Chrome
@@ -37,7 +38,7 @@ RUN curl -sS https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -
37
  && apt-get install -y google-chrome-stable \
38
  && rm -rf /var/lib/apt/lists/*
39
 
40
- # Install ChromeDriver
41
  RUN CHROME_VERSION=$(google-chrome-stable --version | awk -F '[ .]' '{print $3"."$4"."$5"."$6}') \
42
  && wget -q "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" \
43
  && unzip chromedriver-linux64.zip \
@@ -47,8 +48,6 @@ RUN CHROME_VERSION=$(google-chrome-stable --version | awk -F '[ .]' '{print $3".
47
 
48
  # Create non-root user and setup directories
49
  RUN useradd -m -u 1000 user \
50
- && mkdir -p /tmp/.X11-unix \
51
- && chmod 1777 /tmp/.X11-unix \
52
  && mkdir -p /tmp/runtime-user \
53
  && chown user:user /tmp/runtime-user \
54
  && chmod 700 /tmp/runtime-user
@@ -58,7 +57,8 @@ WORKDIR /app
58
 
59
  # Install Python dependencies
60
  COPY --chown=user requirements.txt .
61
- RUN pip install --no-cache-dir --user -r requirements.txt
 
62
 
63
  # Copy application files
64
  COPY --chown=user . .
@@ -73,5 +73,5 @@ COPY --chown=user entrypoint.sh .
73
  RUN chmod +x entrypoint.sh
74
  ENTRYPOINT ["./entrypoint.sh"]
75
 
76
- # Run application
77
  CMD ["python3", "app.py"]
 
4
  # Set up environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive \
6
  PYTHONUNBUFFERED=1 \
7
+ PATH="/usr/bin:/home/user/.local/bin:$PATH" \
8
  XDG_RUNTIME_DIR=/tmp/runtime-user
9
 
10
+ # Install system dependencies including Python 3.10
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  ca-certificates \
13
  curl \
 
24
  libgtk-3-0 \
25
  libgbm-dev \
26
  libxshmfence1 \
27
+ python3.10 \
28
+ python3.10-dev \
29
+ python3.10-distutils \
30
  && rm -rf /var/lib/apt/lists/* \
31
+ && ln -s /usr/bin/python3.10 /usr/bin/python3 \
32
  && ln -s /usr/bin/python3 /usr/bin/python
33
 
34
  # Install Chrome
 
38
  && apt-get install -y google-chrome-stable \
39
  && rm -rf /var/lib/apt/lists/*
40
 
41
+ # Install ChromeDriver using Chrome for Testing
42
  RUN CHROME_VERSION=$(google-chrome-stable --version | awk -F '[ .]' '{print $3"."$4"."$5"."$6}') \
43
  && wget -q "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" \
44
  && unzip chromedriver-linux64.zip \
 
48
 
49
  # Create non-root user and setup directories
50
  RUN useradd -m -u 1000 user \
 
 
51
  && mkdir -p /tmp/runtime-user \
52
  && chown user:user /tmp/runtime-user \
53
  && chmod 700 /tmp/runtime-user
 
57
 
58
  # Install Python dependencies
59
  COPY --chown=user requirements.txt .
60
+ RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 \
61
+ && pip install --no-cache-dir --user -r requirements.txt
62
 
63
  # Copy application files
64
  COPY --chown=user . .
 
73
  RUN chmod +x entrypoint.sh
74
  ENTRYPOINT ["./entrypoint.sh"]
75
 
76
+ # Run application with explicit Python 3.10
77
  CMD ["python3", "app.py"]
entrypoint.sh CHANGED
@@ -1,16 +1,12 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- # Ensure X11 directory exists
5
- mkdir -p /tmp/.X11-unix
6
- chmod 1777 /tmp/.X11-unix
7
-
8
- # Start virtual display
9
- Xvfb :99 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &
10
  export DISPLAY=:99
 
11
 
12
  # Human-like random delay
13
  sleep $(( RANDOM % 3 + 1 ))
14
 
15
- # Execute command
16
  exec "$@"
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # Configure X11 to use TCP instead of UNIX sockets
 
 
 
 
 
5
  export DISPLAY=:99
6
+ Xvfb $DISPLAY -screen 0 1920x1080x24 -ac +extension GLX +render -noreset -listen tcp &
7
 
8
  # Human-like random delay
9
  sleep $(( RANDOM % 3 + 1 ))
10
 
11
+ # Execute command with explicit Python path
12
  exec "$@"