From 68f7bd31add3db4b30caabb0b805ac5fe612dfb0 Mon Sep 17 00:00:00 2001 From: lasse Date: Tue, 1 Apr 2025 08:45:17 +0000 Subject: [PATCH] Upload files to "/" --- pyDockerfile | 30 ++++++++++++++++++++++++++++++ requirements.txt | 17 +++++++++++++++++ seleniumDockerfile | 31 +++++++++++++++++++++++++++++++ statusAndStopScript.sh | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 pyDockerfile create mode 100644 requirements.txt create mode 100644 seleniumDockerfile create mode 100644 statusAndStopScript.sh diff --git a/pyDockerfile b/pyDockerfile new file mode 100644 index 0000000..07a010b --- /dev/null +++ b/pyDockerfile @@ -0,0 +1,30 @@ +#use this image for large python programms +#it is larger than the alpine image, +#but has many python packages preinstalled and it is easy to install new ones +FROM python:3.10-bullseye + + + +#RUN rm -r /pyapp +#will be the working directory later + RUN mkdir /pyapp +#sets the new working directory +WORKDIR /pyapp + + + +#install required packages +ADD requirements.txt . +RUN pip install -r requirements.txt + + + + +#unbuffered output to stdout +#used it that Python gives out all prints, if not, it will buffer them until many prints done +ENV PYTHONUNBUFFERED 1 + +#copies the whole directory into the working directory +COPY . /pyapp/ + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1226104 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +psycopg2-binary==2.9.6 +numpy==1.23.5 +sqlalchemy==2.0.15 +SQLAlchemy-Utils==0.41.1 +selenium==4.9.0 +pandas==2.0.3 + + + + + + + + + + + diff --git a/seleniumDockerfile b/seleniumDockerfile new file mode 100644 index 0000000..ff46aed --- /dev/null +++ b/seleniumDockerfile @@ -0,0 +1,31 @@ +#image that has selenium and chrome installed, official by selenium +FROM selenium/standalone-chrome:4.10.0-20230607 + + + +#will be the working directory later +#RUN mkdir /pyapp +#sets the new working directory +WORKDIR /pyapp + +#user permissions heikel !!!!! +USER root +RUN apt-get update && apt-get install -y \ + python3-pip +#install required packages +ADD requirements.txt . +RUN pip3 install -r requirements.txt --user +RUN export PATH=/home/seluser/.local/bin:$PATH + + +USER 1001 + + +#unbuffered output to stdout +#used it that Python gives out all prints, if not, it will buffer them until many prints done +ENV PYTHONUNBUFFERED 1 + +#copies the whole directory into the working directory +COPY . /pyapp/ + + diff --git a/statusAndStopScript.sh b/statusAndStopScript.sh new file mode 100644 index 0000000..0fe0b92 --- /dev/null +++ b/statusAndStopScript.sh @@ -0,0 +1,35 @@ + +#while running +#wait 10 seconds +#docker stop of containers that only run for containers that already stopped +#e.g. dobby and selenium + + + + +#first have to start all containers +sleep 20 + +#checks status of dobby container and saves into json file +docker inspect py_extract_dobby_test_vimes > outputInspect.json +#check if that container still running +outputRunning=$(jq '.[0].State.Running' outputInspect.json) + + + + +#sleep as long as dobby +while $outputRunning +do + echo $(date) + sleep 10 + + #checks status of dobby container and saves into json file + docker inspect py_extract_dobby_test_vimes > outputInspect.json + #check if that container still running + outputRunning=$(jq '.[0].State.Running' outputInspect.json) + +done + +#since dobby is done reading out data, we can stop the selenium container +docker stop "sel_browser_test_vimes" \ No newline at end of file