mirror of
https://github.com/iv-org/youtube-trusted-session-generator.git
synced 2024-11-23 05:49:57 +00:00
builtin a x11 environment in docker
This commit is contained in:
parent
cd25c70d17
commit
48f25566fa
21
Dockerfile
21
Dockerfile
@ -1,18 +1,29 @@
|
||||
FROM python:3.12-alpine
|
||||
|
||||
|
||||
# Install dependencies
|
||||
RUN apk add --no-cache \
|
||||
chromium \
|
||||
xvfb \
|
||||
x11vnc \
|
||||
fluxbox \
|
||||
nss \
|
||||
freetype \
|
||||
freetype-dev \
|
||||
harfbuzz \
|
||||
ca-certificates \
|
||||
ttf-freefont
|
||||
ttf-freefont \
|
||||
chromium \
|
||||
chromium-chromedriver
|
||||
|
||||
# Install x11vnc
|
||||
RUN mkdir ~/.vnc
|
||||
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
|
||||
|
||||
WORKDIR /usr/app/src
|
||||
COPY index.py requirements.txt ./
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY docker/scripts/startup.sh ./
|
||||
|
||||
# Run
|
||||
CMD [ "python", "./index.py"]
|
||||
CMD [ "./startup.sh"]
|
22
docker/scripts/startup.sh
Executable file
22
docker/scripts/startup.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "internally launching GUI (X11 environment)"
|
||||
|
||||
rm -f /tmp/.X0-lock
|
||||
|
||||
# Run Xvfb on display 0.
|
||||
Xvfb :0 -screen 0 1280x720x16 &>/dev/null &
|
||||
|
||||
# Run fluxbox windows manager on display 0.
|
||||
fluxbox -display :0 &>/dev/null &
|
||||
|
||||
# Run x11vnc on display 0
|
||||
x11vnc -display :0 -forever -usepw &>/dev/null &
|
||||
|
||||
# Add delay
|
||||
sleep 5
|
||||
|
||||
echo "launching the python script"
|
||||
|
||||
# Run python script on display 0
|
||||
DISPLAY=:0 python index.py
|
2
index.py
2
index.py
@ -6,7 +6,7 @@ import sys
|
||||
|
||||
async def main():
|
||||
tab_url = 'https://www.google.com/search?q=me+at+the+zoo&tbm=vid&source=lnms&hl=en&lr=lang_us'
|
||||
browser = await start(headless=True)
|
||||
browser = await start(headless=False)
|
||||
tab = browser.main_tab
|
||||
page = await browser.get(tab_url)
|
||||
accept_terms = await tab.find("Accept all")
|
||||
|
Loading…
Reference in New Issue
Block a user