|
| 1 | +# Docker Compose Changes - New Scheduling Features |
| 2 | + |
| 3 | +This document summarizes the changes made to the Docker Compose configuration to support the new `--run` and `--schedule` functionality. |
| 4 | + |
| 5 | +## Overview of Changes |
| 6 | + |
| 7 | +The Docker Compose configuration has been significantly enhanced to support three execution modes: |
| 8 | + |
| 9 | +1. **Immediate Execution (`--run`)**: Execute once and exit |
| 10 | +2. **Scheduled Execution (`--schedule`)**: Run on a cron schedule |
| 11 | +3. **Legacy Mode**: Traditional command-based approach (for backward compatibility) |
| 12 | + |
| 13 | +## New Services Added |
| 14 | + |
| 15 | +### Immediate Execution Services (`--run`) |
| 16 | + |
| 17 | +| Service Name | Profile | Command | Purpose | |
| 18 | +| ----------------------------- | ---------------- | ----------------------------------------- | ----------------------------- | |
| 19 | +| `export-trakt-run-watched` | `run-watched` | `--run --export watched --mode normal` | Export watched movies only | |
| 20 | +| `export-trakt-run-all` | `run-all` | `--run --export all --mode complete` | Export all data (recommended) | |
| 21 | +| `export-trakt-run-collection` | `run-collection` | `--run --export collection --mode normal` | Export collection only | |
| 22 | +| `export-trakt-run-ratings` | `run-ratings` | `--run --export ratings --mode complete` | Export ratings only | |
| 23 | +| `export-trakt-run-watchlist` | `run-watchlist` | `--run --export watchlist --mode normal` | Export watchlist only | |
| 24 | +| `export-trakt-run-shows` | `run-shows` | `--run --export shows --mode complete` | Export shows only | |
| 25 | + |
| 26 | +### Scheduled Execution Services (`--schedule`) |
| 27 | + |
| 28 | +| Service Name | Profile | Schedule | Command | Purpose | |
| 29 | +| ------------------------------ | ----------------- | ------------------ | ---------------------------------------------------------- | ---------------------- | |
| 30 | +| `export-trakt-schedule-6h` | `schedule-6h` | Every 6 hours | `--schedule "0 */6 * * *" --export all --mode complete` | Production scheduler | |
| 31 | +| `export-trakt-schedule-daily` | `schedule-daily` | Daily at 2:30 AM | `--schedule "30 2 * * *" --export all --mode complete` | Daily backup | |
| 32 | +| `export-trakt-schedule-weekly` | `schedule-weekly` | Sundays at 3:00 AM | `--schedule "0 3 * * 0" --export all --mode complete` | Weekly backup | |
| 33 | +| `export-trakt-schedule-15min` | `schedule-15min` | Every 15 minutes | `--schedule "*/15 * * * *" --export watched --mode normal` | High-frequency testing | |
| 34 | +| `export-trakt-schedule-custom` | `schedule-custom` | Configurable | Custom via env vars | Custom schedule | |
| 35 | + |
| 36 | +## Profile Organization |
| 37 | + |
| 38 | +### New Profiles |
| 39 | + |
| 40 | +- **Immediate Execution**: `run`, `run-watched`, `run-all`, `run-collection`, `run-ratings`, `run-watchlist`, `run-shows` |
| 41 | +- **Scheduled Execution**: `schedule`, `schedule-6h`, `schedule-daily`, `schedule-weekly`, `schedule-15min`, `schedule-test`, `schedule-custom` |
| 42 | +- **Legacy Compatibility**: `legacy`, `legacy-scheduled` |
| 43 | + |
| 44 | +### Updated Profiles |
| 45 | + |
| 46 | +- **Default/Export**: Maintained for backward compatibility, now also tagged as `legacy` |
| 47 | +- **Complete/Initial**: Now also tagged as `legacy` |
| 48 | +- **Scheduled**: Now tagged as `legacy-scheduled` |
| 49 | + |
| 50 | +## Configuration Changes |
| 51 | + |
| 52 | +### Removed Obsolete Version |
| 53 | + |
| 54 | +```yaml |
| 55 | +# REMOVED |
| 56 | +version: "3.8" |
| 57 | +``` |
| 58 | +
|
| 59 | +The `version` attribute is no longer needed in modern Docker Compose. |
| 60 | + |
| 61 | +### Enhanced Custom Scheduler |
| 62 | + |
| 63 | +The `schedule-custom` service now properly handles environment variables: |
| 64 | + |
| 65 | +```yaml |
| 66 | +export-trakt-schedule-custom: |
| 67 | + <<: *export-trakt-base |
| 68 | + profiles: ["schedule-custom"] |
| 69 | + container_name: export-trakt-schedule-custom |
| 70 | + restart: unless-stopped |
| 71 | + environment: |
| 72 | + - TZ=UTC |
| 73 | + - CUSTOM_SCHEDULE=${SCHEDULE:-0 */6 * * *} |
| 74 | + - CUSTOM_EXPORT_TYPE=${EXPORT_TYPE:-all} |
| 75 | + - CUSTOM_EXPORT_MODE=${EXPORT_MODE:-complete} |
| 76 | + entrypoint: ["/bin/sh", "-c"] |
| 77 | + command: |
| 78 | + - | |
| 79 | + /app/export-trakt --schedule "$${CUSTOM_SCHEDULE}" --export "$${CUSTOM_EXPORT_TYPE}" --mode "$${CUSTOM_EXPORT_MODE}" |
| 80 | +``` |
| 81 | + |
| 82 | +## Usage Examples |
| 83 | + |
| 84 | +### Quick Commands |
| 85 | + |
| 86 | +```bash |
| 87 | +# Test configuration |
| 88 | +docker compose --profile run-watched up |
| 89 | +
|
| 90 | +# Export all data once |
| 91 | +docker compose --profile run-all up |
| 92 | +
|
| 93 | +# Start production scheduler |
| 94 | +docker compose --profile schedule-6h up -d |
| 95 | +
|
| 96 | +# Custom schedule |
| 97 | +SCHEDULE="0 */4 * * *" EXPORT_TYPE="watched" EXPORT_MODE="normal" \ |
| 98 | +docker compose --profile schedule-custom up -d |
| 99 | +``` |
| 100 | + |
| 101 | +### Migration from Legacy |
| 102 | + |
| 103 | +| Old Command | New Equivalent | |
| 104 | +| ------------------------------------------ | -------------------------------------------- | |
| 105 | +| `docker compose up` | `docker compose --profile run-watched up` | |
| 106 | +| `docker compose --profile complete up` | `docker compose --profile run-all up` | |
| 107 | +| `docker compose --profile scheduled up -d` | `docker compose --profile schedule-6h up -d` | |
| 108 | + |
| 109 | +## Documentation Added |
| 110 | + |
| 111 | +### New Files |
| 112 | + |
| 113 | +1. **`docker/README.md`**: Comprehensive Docker usage guide |
| 114 | +2. **`docker/test-docker.sh`**: Test script for Docker functionality |
| 115 | +3. **`DOCKER_CHANGES.md`**: This file documenting changes |
| 116 | + |
| 117 | +### Updated Files |
| 118 | + |
| 119 | +1. **`docker-compose.yml`**: Complete restructure with new services |
| 120 | +2. **Comment section**: Detailed usage examples in the compose file |
| 121 | + |
| 122 | +## Benefits |
| 123 | + |
| 124 | +### For Users |
| 125 | + |
| 126 | +- **Simplified Usage**: Clear profiles for different use cases |
| 127 | +- **Flexible Scheduling**: Multiple pre-configured schedules |
| 128 | +- **Better Testing**: Dedicated test profiles |
| 129 | +- **Backward Compatibility**: Legacy services still work |
| 130 | + |
| 131 | +### For Development |
| 132 | + |
| 133 | +- **Modular Design**: Each service has a specific purpose |
| 134 | +- **Easy Extension**: Adding new schedules is straightforward |
| 135 | +- **Clear Separation**: Different modes are clearly separated |
| 136 | +- **Maintainable**: Well-documented and organized |
| 137 | + |
| 138 | +## Testing |
| 139 | + |
| 140 | +The changes have been tested with: |
| 141 | + |
| 142 | +- ✅ Docker Compose syntax validation (`docker compose config`) |
| 143 | +- ✅ Profile listing (`docker compose config --profiles`) |
| 144 | +- ✅ Service validation with test script |
| 145 | +- ✅ Environment variable handling |
| 146 | +- ✅ Backward compatibility |
| 147 | + |
| 148 | +## Backward Compatibility |
| 149 | + |
| 150 | +All existing commands continue to work: |
| 151 | + |
| 152 | +- `docker compose up` (default export) |
| 153 | +- `docker compose --profile setup up` (setup) |
| 154 | +- `docker compose --profile complete up` (complete export) |
| 155 | +- `docker compose --profile scheduled up -d` (legacy scheduler) |
| 156 | + |
| 157 | +## Future Enhancements |
| 158 | + |
| 159 | +The new structure makes it easy to add: |
| 160 | + |
| 161 | +- Additional schedule presets |
| 162 | +- Different export configurations |
| 163 | +- Health checks |
| 164 | +- Monitoring integrations |
| 165 | +- Resource limits |
| 166 | + |
| 167 | +This Docker Compose update provides a solid foundation for both current users and future feature development! |
0 commit comments