Pull-based GitOps-style Docker Compose deployer: polls a (private) Git repo, detects changed stacks and reconciles only the affected

feat: add instructions for crontab

Signed-off-by: A. Ottr <alex@otter.foo>

+26 -13
+26 -13
README.md
··· 8 8 1. Have changed since the last pull 9 9 2. Are assigned to the current host 10 10 11 + ## How It Works 12 + 13 + 1. **Host Detection**: The tool uses the system hostname to identify the current host 14 + 2. **Stack Assignment**: Reads `inventory.yml` to determine which stacks should be deployed on this host 15 + 3. **Change Detection**: Compares git commits before and after pulling to find changed stacks 16 + 4. **Selective Deployment**: Only deploys stacks that both changed AND are assigned to this host 17 + 11 18 ## Repository Structure 12 19 13 20 Your git repository should have the following structure: ··· 34 41 - nextcloud 35 42 ``` 36 43 37 - This format is compatible with Ansible inventory structures and provides a centralized view of all host assignments. 44 + ## Requirements 45 + 46 + - Go 1.21 or later 47 + - Git 48 + - Docker and Docker Compose 49 + - A git repository with the structure described above 38 50 39 51 ## Installation 40 52 ··· 83 95 ./compose-sync -config /path/to/config.yml 84 96 ``` 85 97 86 - ### Systemd Service and Timer (Automatic Execution) 98 + ## Automatic Execution 99 + 100 + ### Systemd Service and Timer 87 101 88 102 To run compose-sync automatically using systemd: 89 103 ··· 121 135 122 136 The timer will run compose-sync every 5 minutes. To change the interval, edit `compose-sync.timer` and modify the `OnUnitActiveSec` value. 123 137 124 - ## How It Works 138 + ### Cron Job (Alternative) 125 139 126 - 1. **Host Detection**: The tool uses the system hostname to identify the current host 127 - 2. **Stack Assignment**: Reads `inventory.yml` to determine which stacks should be deployed on this host 128 - 3. **Change Detection**: Compares git commits before and after pulling to find changed stacks 129 - 4. **Selective Deployment**: Only deploys stacks that both changed AND are assigned to this host 140 + To run compose-sync using cron instead of systemd: 130 141 131 - ## Requirements 132 - 133 - - Go 1.21 or later 134 - - Git 135 - - Docker and Docker Compose 136 - - A git repository with the structure described above 142 + 1. **Install the cron job**: 143 + ```bash 144 + crontab -e 145 + ``` 146 + Then add the desired crontab job, for example (every 5min, defaults, logging): 147 + ```bash 148 + */5 * * * * /usr/local/bin/compose-sync >> /var/log/compose-sync.log 2>&1 149 + ``` 137 150 138 151 ## License 139 152