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:
20
README.md
20
README.md
@@ -9,7 +9,7 @@ A Dockerized Python service that periodically synchronizes an external Outlook I
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
- Docker & Docker Compose installed.
|
- 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.
|
- An Outlook ICS link.
|
||||||
|
|
||||||
## Configuration (Environment Variables)
|
## 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_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_USER` | Your Baïkal username. | **Required** |
|
||||||
| `BAIKAL_PASS` | Your Baïkal password. | **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
|
## Quick Start with Docker Compose
|
||||||
|
|
||||||
@@ -29,16 +29,18 @@ A Dockerized Python service that periodically synchronizes an external Outlook I
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
ICS_URL="https://outlook.office365.com/..."
|
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_USER="Lago"
|
||||||
BAIKAL_PASS="secret"
|
BAIKAL_PASS="secret"
|
||||||
|
SYNC_FREQUENCY=5
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Run with Docker Compose**:
|
3. **Run with Docker Compose**:
|
||||||
|
|
||||||
```bash
|
```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**:
|
4. **Check Logs**:
|
||||||
|
|
||||||
@@ -46,16 +48,14 @@ A Dockerized Python service that periodically synchronizes an external Outlook I
|
|||||||
docker compose logs -f baikal-sync
|
docker compose logs -f baikal-sync
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building & Publishing the Image manually
|
## Building & Publishing the Image
|
||||||
|
|
||||||
If you want to build and push the image to Docker Hub yourself:
|
|
||||||
|
|
||||||
1. **Build**:
|
1. **Build**:
|
||||||
```bash
|
```bash
|
||||||
docker build -t yourusername/baikal-sync:latest .
|
docker build -t lagortinez/baikal-sync:latest .
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Push**:
|
2. **Push** (requires `docker login`):
|
||||||
```bash
|
```bash
|
||||||
docker push yourusername/baikal-sync:latest
|
docker push lagortinez/baikal-sync:latest
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,18 +1,6 @@
|
|||||||
services:
|
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:
|
baikal-sync:
|
||||||
build: .
|
image: lagortinez/baikal-sync:latest
|
||||||
container_name: baikal-sync
|
container_name: baikal-sync
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
@@ -20,10 +8,7 @@ services:
|
|||||||
- BAIKAL_URL=${BAIKAL_URL}
|
- BAIKAL_URL=${BAIKAL_URL}
|
||||||
- BAIKAL_USER=${BAIKAL_USER}
|
- BAIKAL_USER=${BAIKAL_USER}
|
||||||
- BAIKAL_PASS=${BAIKAL_PASS}
|
- BAIKAL_PASS=${BAIKAL_PASS}
|
||||||
- SYNC_FREQUENCY=300 # 5 minutes default
|
- SYNC_FREQUENCY=5 # Minutes
|
||||||
depends_on:
|
# If your Baikal is on the same host, you might need network_mode: "host"
|
||||||
- baikal
|
# or ensure they share a network.
|
||||||
|
# network_mode: "host"
|
||||||
volumes:
|
|
||||||
baikal_data:
|
|
||||||
baikal_db:
|
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ import os
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
# --- CONFIGURACIÓN ---
|
# --- CONFIGURACIÓN ---
|
||||||
# Default to 5 minutes (300 seconds)
|
# Default to 5 minutes
|
||||||
SYNC_FREQUENCY = int(os.getenv("SYNC_FREQUENCY", 300))
|
SYNC_FREQUENCY_MINUTES = int(os.getenv("SYNC_FREQUENCY", 5))
|
||||||
|
SYNC_FREQUENCY_SECONDS = SYNC_FREQUENCY_MINUTES * 60
|
||||||
|
|
||||||
# Tu URL de Outlook
|
# Tu URL de Outlook
|
||||||
ICS_URL = os.getenv("ICS_URL")
|
ICS_URL = os.getenv("ICS_URL")
|
||||||
@@ -95,8 +96,8 @@ def sync():
|
|||||||
print(f"!!! Error en Baïkal: {e}")
|
print(f"!!! Error en Baïkal: {e}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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:
|
while True:
|
||||||
sync()
|
sync()
|
||||||
print(f"[{datetime.now()}] Durmiendo {SYNC_FREQUENCY} segundos...")
|
print(f"[{datetime.now()}] Durmiendo {SYNC_FREQUENCY_MINUTES} minutos...")
|
||||||
time.sleep(SYNC_FREQUENCY)
|
time.sleep(SYNC_FREQUENCY_SECONDS)
|
||||||
|
|||||||
Reference in New Issue
Block a user