|
1 | 1 | version: "3.8" |
2 | 2 |
|
3 | 3 | services: |
4 | | - # Default service - runs once and exits |
5 | | - trakt-export: |
6 | | - build: |
7 | | - context: . |
8 | | - args: |
9 | | - - APP_VERSION=dev |
10 | | - - BUILD_DATE=${BUILD_DATE:-unknown} |
11 | | - - VCS_REF=${VCS_REF:-unknown} |
12 | | - container_name: trakt-export |
| 4 | + # Base service configuration (not started directly) |
| 5 | + export-trakt-base: &export-trakt-base |
| 6 | + image: johandevl/export-trakt-4-letterboxd:latest |
| 7 | + container_name: export-trakt |
13 | 8 | volumes: |
14 | 9 | - ./config:/app/config |
15 | 10 | - ./logs:/app/logs |
16 | | - - ./copy:/app/copy |
17 | | - - ./backup:/app/backup |
18 | | - environment: |
19 | | - - TZ=Europe/Paris |
20 | | - # Leave CRON_SCHEDULE empty to run once and exit |
21 | | - - EXPORT_OPTION=complete |
| 11 | + - ./exports:/app/exports |
22 | 12 | restart: "no" |
23 | | - stdin_open: true |
| 13 | + environment: |
| 14 | + - TZ=UTC |
| 15 | + |
| 16 | + # Normal export (default) |
| 17 | + export-trakt: |
| 18 | + <<: *export-trakt-base |
| 19 | + profiles: ["default", "export"] |
| 20 | + command: ["export", "--mode", "normal"] |
| 21 | + |
| 22 | + # Interactive setup |
| 23 | + export-trakt-setup: |
| 24 | + <<: *export-trakt-base |
| 25 | + profiles: ["setup"] |
| 26 | + command: ["setup"] |
| 27 | + # Interactive TTY for setup process |
24 | 28 | tty: true |
25 | | - healthcheck: |
26 | | - test: ["CMD", "/app/docker-entrypoint.sh", "healthcheck"] |
27 | | - interval: 30s |
28 | | - timeout: 10s |
29 | | - retries: 3 |
30 | | - start_period: 5s |
| 29 | + stdin_open: true |
31 | 30 |
|
32 | | - # Service that runs on a schedule using cron |
33 | | - trakt-export-scheduled: |
34 | | - profiles: ["scheduled"] |
35 | | - build: |
36 | | - context: . |
37 | | - args: |
38 | | - - APP_VERSION=dev |
39 | | - container_name: trakt-export-scheduled |
40 | | - volumes: |
41 | | - - ./config:/app/config |
42 | | - - ./logs:/app/logs |
43 | | - - ./copy:/app/copy |
44 | | - - ./backup:/app/backup |
45 | | - environment: |
46 | | - - TZ=Europe/Paris |
47 | | - - CRON_SCHEDULE=* * * * * |
48 | | - - EXPORT_OPTION=complete |
49 | | - restart: unless-stopped |
50 | | - healthcheck: |
51 | | - test: ["CMD", "/app/docker-entrypoint.sh", "healthcheck"] |
52 | | - interval: 1m |
53 | | - timeout: 10s |
54 | | - retries: 3 |
55 | | - start_period: 30s |
| 31 | + # Complete export |
| 32 | + export-trakt-complete: |
| 33 | + <<: *export-trakt-base |
| 34 | + profiles: ["complete"] |
| 35 | + command: ["export", "--mode", "complete"] |
56 | 36 |
|
57 | | - # Service that runs on a schedule using cron |
58 | | - trakt-export-scheduled-repo: |
59 | | - #image: ghcr.io/johandevl/export_trakt_4_letterboxd:pr-29 |
60 | | - build: |
61 | | - context: . |
62 | | - args: |
63 | | - - APP_VERSION=dev |
64 | | - container_name: trakt-export-scheduled-repo |
65 | | - volumes: |
66 | | - - ./config:/app/config |
67 | | - - ./logs:/app/logs |
68 | | - - ./copy:/app/copy |
69 | | - - ./backup:/app/backup |
70 | | - environment: |
71 | | - - TZ=Europe/Paris |
72 | | - # Run every day at 3 AM |
73 | | - - CRON_SCHEDULE=* * * * * |
74 | | - - EXPORT_OPTION=normal |
75 | | - restart: unless-stopped |
76 | | - healthcheck: |
77 | | - test: ["CMD", "/app/docker-entrypoint.sh", "healthcheck"] |
78 | | - interval: 1m |
79 | | - timeout: 10s |
80 | | - retries: 3 |
81 | | - start_period: 30s |
| 37 | + # Initial export |
| 38 | + export-trakt-initial: |
| 39 | + <<: *export-trakt-base |
| 40 | + profiles: ["initial"] |
| 41 | + command: ["export", "--mode", "initial"] |
| 42 | + |
| 43 | + # Validate configuration |
| 44 | + export-trakt-validate: |
| 45 | + <<: *export-trakt-base |
| 46 | + profiles: ["validate"] |
| 47 | + command: ["validate"] |
82 | 48 |
|
83 | | - # Example with all configuration passed via environment variables |
84 | | - trakt-export-env: |
85 | | - profiles: ["env-config"] |
| 49 | + # Scheduled export (runs as cron job) |
| 50 | + export-trakt-scheduled: |
| 51 | + <<: *export-trakt-base |
| 52 | + profiles: ["scheduled"] |
86 | 53 | image: johandevl/export-trakt-4-letterboxd:latest |
87 | | - container_name: trakt-export-env |
88 | | - volumes: |
89 | | - - trakt_logs:/app/logs |
90 | | - - trakt_copy:/app/copy |
91 | | - - trakt_backup:/app/backup |
92 | | - environment: |
93 | | - - TZ=Europe/Paris |
94 | | - # API configuration - replace with your actual values |
95 | | - - TRAKT_API_KEY=${TRAKT_API_KEY} |
96 | | - - TRAKT_API_SECRET=${TRAKT_API_SECRET} |
97 | | - - TRAKT_ACCESS_TOKEN=${TRAKT_ACCESS_TOKEN} |
98 | | - - TRAKT_REFRESH_TOKEN=${TRAKT_REFRESH_TOKEN} |
99 | | - - TRAKT_USERNAME=${TRAKT_USERNAME} |
100 | | - # Schedule and export options |
101 | | - - CRON_SCHEDULE=0 3 * * * |
102 | | - - EXPORT_OPTION=normal |
103 | 54 | restart: unless-stopped |
104 | | - healthcheck: |
105 | | - test: ["CMD", "/app/docker-entrypoint.sh", "healthcheck"] |
106 | | - interval: 1m |
107 | | - timeout: 10s |
108 | | - retries: 3 |
109 | | - |
110 | | - # Setup command - use this to run the initial setup |
111 | | - trakt-setup: |
112 | | - profiles: ["setup"] |
113 | | - build: . |
114 | | - container_name: trakt-setup |
115 | | - volumes: |
116 | | - - ./config:/app/config |
| 55 | + # This entrypoint overrides the default to run as a cron job |
| 56 | + entrypoint: ["/bin/sh", "-c"] |
| 57 | + # Run every day at 2 AM |
| 58 | + command: > |
| 59 | + " |
| 60 | + echo \"$$EXPORT_SCHEDULE\" > /tmp/crontab && |
| 61 | + echo \"# Run Export Trakt for Letterboxd\" >> /tmp/crontab && |
| 62 | + echo \"$$EXPORT_SCHEDULE /app/export-trakt export >> /app/logs/cron.log 2>&1\" >> /tmp/crontab && |
| 63 | + crond -f -d 8 -c /tmp |
| 64 | + " |
117 | 65 | environment: |
118 | | - - TZ=Europe/Paris |
119 | | - entrypoint: ["/app/docker-entrypoint.sh", "setup"] |
120 | | - stdin_open: true # Needed for interactive prompts |
121 | | - tty: true # Needed for interactive prompts |
| 66 | + - TZ=UTC |
| 67 | + - EXPORT_SCHEDULE=0 2 * * * # Run every day at 2 AM |
| 68 | + |
| 69 | +# Docker Compose usage examples: |
| 70 | +# |
| 71 | +# Default export (normal mode): |
| 72 | +# docker-compose up |
| 73 | +# |
| 74 | +# Interactive setup: |
| 75 | +# docker-compose --profile setup up |
| 76 | +# |
| 77 | +# Complete export: |
| 78 | +# docker-compose --profile complete up |
| 79 | +# |
| 80 | +# Initial export: |
| 81 | +# docker-compose --profile initial up |
| 82 | +# |
| 83 | +# Validate configuration: |
| 84 | +# docker-compose --profile validate up |
| 85 | +# |
| 86 | +# Scheduled export (runs as cron job): |
| 87 | +# docker-compose --profile scheduled up -d |
122 | 88 |
|
123 | 89 | volumes: |
124 | 90 | trakt_logs: |
|
0 commit comments