From 4e009a1d7bf29f40098e323dc7429674ba602ec1 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Wed, 6 Sep 2023 01:12:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D1=83=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 28 ++++++++++++++++++++++++++++ crontab | 2 ++ main.py | 16 +++++++++------- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100644 crontab diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0296f4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:3.11.2-alpine3.17 + +LABEL Maintainer="serega404" + +ENV MUSL_LOCALE_DEPS cmake make musl-dev gcc gettext-dev libintl +ENV MUSL_LOCPATH /usr/share/i18n/locales/musl + +RUN apk add --no-cache \ + $MUSL_LOCALE_DEPS \ + && wget https://gitlab.com/rilian-la-te/musl-locales/-/archive/master/musl-locales-master.zip \ + && unzip musl-locales-master.zip \ + && cd musl-locales-master \ + && cmake -DLOCALE_PROFILE=OFF -D CMAKE_INSTALL_PREFIX:PATH=/usr . && make && make install \ + && cd .. && rm -r musl-locales-master + +WORKDIR /app + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +# Setting up crontab +COPY crontab /tmp/crontab +RUN cat /tmp/crontab > /etc/crontabs/root + +COPY main.py main.py + +# run crond as main process of container +CMD ["crond", "-f", "-l", "2"] \ No newline at end of file diff --git a/crontab b/crontab new file mode 100644 index 0000000..86a06e2 --- /dev/null +++ b/crontab @@ -0,0 +1,2 @@ +@reboot cd /app && python3 /app/main.py +0 */6 * * * cd /app && python3 /app/main.py diff --git a/main.py b/main.py index 4ffcab4..ad277f4 100644 --- a/main.py +++ b/main.py @@ -26,13 +26,14 @@ else: url = "https://www.kinoneo.ru" + title.parent.get('href') imamgeurl = "https://www.kinoneo.ru" + tag.find("img").get('src') jsonout = { - "city": "Таганрог", - "cinema": "КиноНЕО", - "filmName": title.text, - "genre": genre, - "url": url, - "imageUrl": imamgeurl - } + "city": "Таганрог", + "cinema": "КиноНЕО", + "filmName": title.text, + "genre": genre, + "url": url, + "imageUrl": imamgeurl + } + print("КиноНЕО | Найден фильм: " + title.text) elements.append(jsonout) headers = {"X-Platform": "widget", "X-Application-Token": "KMwvMv7qwz4IVNMu48cTot3PBNnYrifO"} @@ -55,6 +56,7 @@ else: "url": "https://kinocharly.ru/51/release/" + str(release["id"]) + "?date=" + curDate, "imageUrl": release["poster"] } + print("Чарли | Найден фильм: " + release["title"]) elements.append(json) request = requests.post(API_URL, json = elements)