From a934d01b1b1eef4b5f5ed2d2e41d2d13b6e024f6 Mon Sep 17 00:00:00 2001 From: LagoESP Date: Thu, 15 Jan 2026 21:42:12 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Standardize=20sync=20frequency=20to=20m?= =?UTF-8?q?inutes,=20remove=20Ba=C3=AFkal=20service=20from=20Docker=20Comp?= =?UTF-8?q?ose,=20and=20utilize=20a=20pre-built=20image=20for=20the=20sync?= =?UTF-8?q?=20container.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++++++++---------- docker-compose.yml | 25 +++++-------------------- sync_calendar.py | 11 ++++++----- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 3e28329..373ae07 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A Dockerized Python service that periodically synchronizes an external Outlook I ## Prerequisites - Docker & Docker Compose installed. -- A running Baïkal instance (included in the example `docker-compose.yml`). +- An existing Baïkal instance. - An Outlook ICS link. ## Configuration (Environment Variables) @@ -20,7 +20,7 @@ A Dockerized Python service that periodically synchronizes an external Outlook I | `BAIKAL_URL` | The URL to your Baïkal calendar (e.g., `http://baikal/dav.php/calendars/user/id/`). | **Required** | | `BAIKAL_USER` | Your Baïkal username. | **Required** | | `BAIKAL_PASS` | Your Baïkal password. | **Required** | -| `SYNC_FREQUENCY` | How often to sync in seconds. | `300` (5 mins) | +| `SYNC_FREQUENCY` | How often to sync **in minutes**. | `5` | ## Quick Start with Docker Compose @@ -29,16 +29,18 @@ A Dockerized Python service that periodically synchronizes an external Outlook I ```bash ICS_URL="https://outlook.office365.com/..." - BAIKAL_URL="http://localhost:8080/dav.php/calendars/Lago/beterna/" + BAIKAL_URL="http://localhost:8080/dav.php/calendars/Lago/default/" BAIKAL_USER="Lago" BAIKAL_PASS="secret" + SYNC_FREQUENCY=5 ``` 3. **Run with Docker Compose**: ```bash - docker compose up -d --build + docker compose up -d ``` + *Note: This will verify the image usage. If you need to rebuild locally, run `docker compose up -d --build`.* 4. **Check Logs**: @@ -46,16 +48,14 @@ A Dockerized Python service that periodically synchronizes an external Outlook I docker compose logs -f baikal-sync ``` -## Building & Publishing the Image manually - -If you want to build and push the image to Docker Hub yourself: +## Building & Publishing the Image 1. **Build**: ```bash - docker build -t yourusername/baikal-sync:latest . + docker build -t lagortinez/baikal-sync:latest . ``` -2. **Push**: +2. **Push** (requires `docker login`): ```bash - docker push yourusername/baikal-sync:latest + docker push lagortinez/baikal-sync:latest ``` diff --git a/docker-compose.yml b/docker-compose.yml index 4cadf6e..60e3517 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,6 @@ services: - baikal: - image: ckulka/baikal:nginx - container_name: baikal - restart: always - ports: - - "8080:80" - environment: - - BAIKAL_SKIP_SSL_CHECKS=true # Optional, helpful for dev - volumes: - - baikal_data:/var/www/baikal/Specific - - baikal_db:/var/www/baikal/database - baikal-sync: - build: . + image: lagortinez/baikal-sync:latest container_name: baikal-sync restart: always environment: @@ -20,10 +8,7 @@ services: - BAIKAL_URL=${BAIKAL_URL} - BAIKAL_USER=${BAIKAL_USER} - BAIKAL_PASS=${BAIKAL_PASS} - - SYNC_FREQUENCY=300 # 5 minutes default - depends_on: - - baikal - -volumes: - baikal_data: - baikal_db: + - SYNC_FREQUENCY=5 # Minutes + # If your Baikal is on the same host, you might need network_mode: "host" + # or ensure they share a network. + # network_mode: "host" diff --git a/sync_calendar.py b/sync_calendar.py index c6efef1..f428e0b 100644 --- a/sync_calendar.py +++ b/sync_calendar.py @@ -6,8 +6,9 @@ import os import time # --- CONFIGURACIÓN --- -# Default to 5 minutes (300 seconds) -SYNC_FREQUENCY = int(os.getenv("SYNC_FREQUENCY", 300)) +# Default to 5 minutes +SYNC_FREQUENCY_MINUTES = int(os.getenv("SYNC_FREQUENCY", 5)) +SYNC_FREQUENCY_SECONDS = SYNC_FREQUENCY_MINUTES * 60 # Tu URL de Outlook ICS_URL = os.getenv("ICS_URL") @@ -95,8 +96,8 @@ def sync(): print(f"!!! Error en Baïkal: {e}") if __name__ == "__main__": - print(f"Iniciando servicio de sincronización. Frecuencia: {SYNC_FREQUENCY} segundos.") + print(f"Iniciando servicio de sincronización. Frecuencia: {SYNC_FREQUENCY_MINUTES} minutos ({SYNC_FREQUENCY_SECONDS} segundos).") while True: sync() - print(f"[{datetime.now()}] Durmiendo {SYNC_FREQUENCY} segundos...") - time.sleep(SYNC_FREQUENCY) + print(f"[{datetime.now()}] Durmiendo {SYNC_FREQUENCY_MINUTES} minutos...") + time.sleep(SYNC_FREQUENCY_SECONDS)