forked from sarperavci/CloudflareBypassForScraping
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (60 loc) · 1.68 KB
/
Dockerfile
File metadata and controls
73 lines (60 loc) · 1.68 KB
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
FROM ubuntu:rolling
# Set environment variables to avoid interactive prompts during build
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies for Chrome and Python packages
USER root
RUN apt-get update && apt-get install -y \
software-properties-common \
python3-pip \
python3-venv \
wget \
gnupg \
curl \
xvfb \
libgtk-3-0 \
libgtk-3-dev \
libxss1 \
libxtst6 \
libxrandr2 \
libasound2t64 \
libpangocairo-1.0-0 \
libatk1.0-0 \
libcairo-gobject2 \
libgdk-pixbuf-2.0-0 \
libdbus-glib-1-2 \
libxt6 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrender1 \
libxi6 \
fonts-liberation \
libnss3 \
lsb-release \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . .
# Copy requirements.txt and install dependencies
COPY requirements.txt .
# Change ownership of app directory to ubuntu first
RUN chown -R ubuntu:ubuntu /app
# Switch to ubuntu user to create venv and install packages
USER ubuntu
# Create and activate virtual environment as ubuntu user
RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
# Install pip and requirements in virtual environment
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r server_requirements.txt
# Fetch Camoufox as ubuntu user
RUN camoufox fetch
# Switch back to root for remaining setup
USER root
WORKDIR /app
# Fix permissions for playwright_captcha addon directory (needs write access at runtime)
RUN chmod -R 777 /app/venv/lib/python*/site-packages/playwright_captcha/utils/camoufox_add_init_script/addon/ || true
# Switch to ubuntu user for runtime
USER ubuntu
# RUN the application
CMD ["python3", "server.py"]