dockerfile update
This commit is contained in:
parent
b40221582d
commit
d2987a5917
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
monitor.service
|
||||
README.md
|
||||
docker-compose.yml
|
||||
.env
|
5
.env
Normal file
5
.env
Normal file
@ -0,0 +1,5 @@
|
||||
TARGET_DOMAINS="google.com,yandex.ru"
|
||||
TARGET_PROTOCOL="https://" # default https
|
||||
TARGET_SSL_VERIFY="True" # default True
|
||||
BOT_TOKEN=""
|
||||
BOT_CHATID=""
|
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM python:3.10-alpine3.20
|
||||
|
||||
WORKDIR /monitor
|
||||
COPY monitor.py .
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r ./requirements.txt
|
||||
|
||||
ENTRYPOINT ["python", "monitor.py"]
|
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
@ -0,0 +1,15 @@
|
||||
version: '3.8'
|
||||
|
||||
# Переменные из .env будут подставлены автоматически
|
||||
# Если .env нет, можно указать явно: docker-compose --env-file .custom.env up
|
||||
|
||||
services:
|
||||
monitor:
|
||||
image: monitor:latest
|
||||
container_name: monitor
|
||||
environment:
|
||||
- TARGET_DOMAINS=${TARGET_DOMAINS} # Список доменов через запятую
|
||||
- TARGET_PROTOCOL=${TARGET_PROTOCOL}
|
||||
- TARGET_SSL_VERIFY=${TARGET_SSL_VERIFY}
|
||||
- BOT_TOKEN=${BOT_TOKEN}
|
||||
- BOT_CHATID=${BOT_CHATID}
|
18
monitor.py
18
monitor.py
@ -4,15 +4,23 @@ import daemon
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # insecure warn disable
|
||||
|
||||
domains = ['google.com', '127.0.0.1']
|
||||
protocol = "https://"
|
||||
token = "TOKEN_YOU_BOT"
|
||||
chatid = YOU_CHAT_ID
|
||||
domains = os.getenv("TARGET_DOMAINS", "").split(',')
|
||||
domains = [d.strip() for d in domains if d.strip()]
|
||||
protocol = os.getenv("TARGET_PROTOCOL", "https://")
|
||||
verify_domain = bool(os.getenv("TARGET_SSL_VERIFY", "True"))
|
||||
token = os.getenv("BOT_TOKEN", "")
|
||||
chatid = int(os.getenv("BOT_CHATID", ""))
|
||||
if not domains or not token or not chatid:
|
||||
print("Error: Plese set domains, tg token, and tg chat id")
|
||||
exit(1)
|
||||
|
||||
print(domains)
|
||||
|
||||
timeout_domains = []
|
||||
|
||||
def CheckDomain(domain):
|
||||
try:
|
||||
r = requests.get(f"{protocol}{domain}", verify=False) # verify SSL crt disable
|
||||
r = requests.get(f"{protocol}{domain}", verify=verify_domain) # verify SSL crt disable
|
||||
code = int(r.status_code)
|
||||
return code
|
||||
except requests.exceptions.ConnectionError:
|
||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests
|
Loading…
x
Reference in New Issue
Block a user