From 2408a8048975e46926aab7600a39aedba10c1d3d Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 17 Mar 2026 19:09:06 -0400 Subject: [PATCH] feat: Docker and systemd deployment files --- Dockerfile | 18 ++++++++++++++++++ docker-compose.yml | 35 +++++++++++++++++++++++++++++++++++ systemd/fablednetmon.service | 15 +++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 systemd/fablednetmon.service diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..85fa594 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY pyproject.toml . +RUN pip install --no-cache-dir -e . + +COPY fablednetmon/ fablednetmon/ +COPY alembic.ini . + +# Runtime directories +RUN mkdir -p /data/playbook_cache /data/plugins + +ENV FABLEDNETMON_CONFIG=/config/config.yaml + +EXPOSE 5000 + +CMD ["fablednetmon", "--host", "0.0.0.0", "--port", "5000"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7530859 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +services: + app: + build: . + ports: + - "5000:5000" + volumes: + - ./config.yaml:/config/config.yaml:ro + - playbook_cache:/data/playbook_cache + - plugins:/data/plugins + environment: + - FABLEDNETMON_DATABASE__URL=postgresql+asyncpg://fablednetmon:fablednetmon@db/fablednetmon + depends_on: + db: + condition: service_healthy + restart: unless-stopped + + db: + image: postgres:16-alpine + environment: + POSTGRES_USER: fablednetmon + POSTGRES_PASSWORD: fablednetmon + POSTGRES_DB: fablednetmon + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U fablednetmon"] + interval: 5s + timeout: 5s + retries: 5 + restart: unless-stopped + +volumes: + pgdata: + playbook_cache: + plugins: diff --git a/systemd/fablednetmon.service b/systemd/fablednetmon.service new file mode 100644 index 0000000..397c6d4 --- /dev/null +++ b/systemd/fablednetmon.service @@ -0,0 +1,15 @@ +[Unit] +Description=FabledNetMon monitoring server +After=network.target postgresql.service + +[Service] +Type=simple +User=fablednetmon +WorkingDirectory=/opt/fablednetmon +ExecStart=/opt/fablednetmon/.venv/bin/fablednetmon --config /etc/fablednetmon/config.yaml +Restart=on-failure +RestartSec=5s +Environment=PYTHONUNBUFFERED=1 + +[Install] +WantedBy=multi-user.target