feat: Standardize sync frequency to minutes, remove Baïkal service from Docker Compose, and utilize a pre-built image for the sync container.

This commit is contained in:
LagoESP
2026-01-15 21:42:12 +01:00
parent cfc6c68aa0
commit a934d01b1b
3 changed files with 21 additions and 35 deletions

View File

@@ -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
```

View File

@@ -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"

View File

@@ -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)