mirror of
https://github.com/eduardogsilva/routerfleet.git
synced 2025-08-04 10:15:00 +02:00
Docker compose and container stuff
This commit is contained in:
parent
7332bca96e
commit
563ee7408e
12 changed files with 187 additions and 2 deletions
16
containers/cron/Dockerfile-cron
Normal file
16
containers/cron/Dockerfile-cron
Normal file
|
@ -0,0 +1,16 @@
|
|||
FROM ubuntu:latest
|
||||
|
||||
# Instalar cron
|
||||
RUN apt-get update && apt-get install -y cron curl
|
||||
|
||||
# Adicionar seus scripts de cron
|
||||
COPY cron_tasks /etc/cron.d/cron_tasks
|
||||
|
||||
# Dar permissões apropriadas
|
||||
RUN chmod 0644 /etc/cron.d/cron_tasks
|
||||
|
||||
# Criar um arquivo de log para armazenar os resultados do cron
|
||||
RUN touch /var/log/cron.log
|
||||
|
||||
# Executar o cron em primeiro plano
|
||||
CMD cron -f
|
5
containers/cron/cron_tasks
Normal file
5
containers/cron/cron_tasks
Normal file
|
@ -0,0 +1,5 @@
|
|||
* * * * * root /usr/bin/curl -s http://routerfleet:8001/cron/check_updates/ >> /var/log/cron.log 2>&1
|
||||
*/5 * * * * root /usr/bin/curl -s http://routerfleet:8001/cron/generate_backup_schedule/ >> /var/log/cron.log 2>&1
|
||||
* * * * * root /usr/bin/curl -s http://routerfleet:8001/cron/create_backup_tasks/ >> /var/log/cron.log 2>&1
|
||||
* * * * * root /usr/bin/curl -s http://routerfleet:8001/cron/perform_backup_tasks/ >> /var/log/cron.log 2>&1
|
||||
*/10 * * * * root /usr/bin/curl -s http://routerfleet:8001/cron/housekeeping/ >> /var/log/cron.log 2>&1
|
17
containers/monitoring/Dockerfile-monitoring
Normal file
17
containers/monitoring/Dockerfile-monitoring
Normal file
|
@ -0,0 +1,17 @@
|
|||
FROM python:3.10
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
net-tools \
|
||||
inetutils-ping \
|
||||
inetutils-traceroute \
|
||||
nano \
|
||||
vim-nox \
|
||||
fping \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY monitoring.py .
|
||||
|
||||
CMD ["python", "-u", "monitoring.py"]
|
|
@ -7,8 +7,8 @@ from subprocess import Popen, PIPE
|
|||
UPDATE_HOST_LIST_INTERVAL = 600 # How often to update the router list in seconds
|
||||
MONITOR_INTERVAL = 60 # How often to monitor each router in seconds
|
||||
MAX_NOTIFICATIONS_PER_MONITOR_INTERVAL = 50 # Throttle the number of notifications sent to the remote API
|
||||
HOST_LIST_URL = "http://127.0.0.1:8000/monitoring/export_router_list/"
|
||||
UPDATE_STATUS_URL = "http://127.0.0.1:8000/monitoring/update_router_status/"
|
||||
HOST_LIST_URL = "http://routerfleet:8001/monitoring/export_router_list/"
|
||||
UPDATE_STATUS_URL = "http://routerfleet:8001/monitoring/update_router_status/"
|
||||
DEBUG = False
|
||||
|
||||
# Global variables
|
||||
|
|
6
containers/nginx/Dockerfile-nginx
Normal file
6
containers/nginx/Dockerfile-nginx
Normal file
|
@ -0,0 +1,6 @@
|
|||
FROM nginx:alpine
|
||||
RUN apk --no-cache add openssl
|
||||
COPY nginx_entrypoint.sh /nginx_entrypoint.sh
|
||||
RUN chmod +x /nginx_entrypoint.sh
|
||||
ENTRYPOINT ["/nginx_entrypoint.sh"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
12
containers/nginx/nginx_entrypoint.sh
Normal file
12
containers/nginx/nginx_entrypoint.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
CERT_DIR="/certificate"
|
||||
|
||||
if [ ! -f "$CERT_DIR/nginx.key" ] || [ ! -f "$CERT_DIR/nginx.pem" ]; then
|
||||
echo "Creating self signed certificate..."
|
||||
openssl req -x509 -newkey rsa:4096 -nodes -keyout "$CERT_DIR/nginx.key" -out "$CERT_DIR/nginx.pem" -days 3650 -subj "/CN=localhost"
|
||||
else
|
||||
echo "Skipping self signed certificate creation, files already exist."
|
||||
fi
|
||||
|
||||
exec "$@"
|
25
containers/nginx/virtualhost.conf
Normal file
25
containers/nginx/virtualhost.conf
Normal file
|
@ -0,0 +1,25 @@
|
|||
server {
|
||||
listen 80;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
ssl_certificate /certificate/nginx.pem;
|
||||
ssl_certificate_key /certificate/nginx.key;
|
||||
|
||||
# if you are using cloudflare, you can use this enable authenticated origin pull. Dont forget to activate it in cloudflare
|
||||
#ssl_client_certificate /certificate/cloudflare_authenticated_origin_pull_ca.pem;
|
||||
#ssl_verify_client on;
|
||||
|
||||
location /static/ {
|
||||
alias /static/;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://routerfleet:8001;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue