Skip to content

Commit 894c675

Browse files
committed
✨ feat: Add auto-configuration creation for Docker containers - Docker Auto-Configuration System with automatic performance.toml creation - Embedded default configuration using Go embed - Smart configuration detection and validation - Docker initialization script for container setup - Container-optimized default values and performance settings
1 parent f50f322 commit 894c675

File tree

7 files changed

+1341
-8
lines changed

7 files changed

+1341
-8
lines changed

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ COPY --from=builder /app/export-trakt /app/export-trakt
4949
# Copy locales
5050
COPY --from=builder /app/locales /app/locales
5151

52+
# Copy initialization script
53+
COPY scripts/docker-init.sh /app/docker-init.sh
54+
RUN chmod +x /app/docker-init.sh
55+
5256
# Set environment variables
5357
ENV EXPORT_TRAKT_EXPORT_OUTPUT_DIR=/app/exports
5458
ENV EXPORT_TRAKT_LOGGING_FILE=/app/logs/export.log
@@ -59,8 +63,8 @@ USER appuser
5963
# Create volumes for persistent data
6064
VOLUME ["/app/config", "/app/logs", "/app/exports"]
6165

62-
# Set entrypoint
63-
ENTRYPOINT ["/app/export-trakt"]
66+
# Set entrypoint to initialization script
67+
ENTRYPOINT ["/app/docker-init.sh"]
6468

6569
# Default command if none is provided
6670
CMD ["--help"]

docker-compose.example.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
version: "3.8"
2+
3+
# ═══════════════════════════════════════════════════════════════════════════════
4+
# EXPORT TRAKT FOR LETTERBOXD
5+
# Docker Compose Example
6+
# ═══════════════════════════════════════════════════════════════════════════════
7+
#
8+
# 🐳 Docker Compose Configuration
9+
# This example shows how to run Export Trakt for Letterboxd with
10+
# automatic configuration file creation.
11+
#
12+
# 📋 Instructions:
13+
# 1. Copy this file to docker-compose.yml
14+
# 2. Set your Trakt.tv API credentials in the environment section
15+
# 3. Customize volumes and environment variables as needed
16+
# 4. Run: docker-compose up
17+
#
18+
# ═══════════════════════════════════════════════════════════════════════════════
19+
20+
services:
21+
export-trakt:
22+
# Use the latest image or build from source
23+
image: johandevl/export-trakt-4-letterboxd:latest
24+
# Uncomment to build from source:
25+
# build: .
26+
27+
container_name: export-trakt-letterboxd
28+
29+
# Environment variables for configuration
30+
environment:
31+
# 🔑 Required: Trakt.tv API Credentials
32+
# Get these from: https://trakt.tv/oauth/applications
33+
TRAKT_CLIENT_ID: "your_trakt_client_id_here"
34+
TRAKT_CLIENT_SECRET: "your_trakt_client_secret_here"
35+
36+
# 🔐 Optional: Access token for authenticated requests
37+
# TRAKT_ACCESS_TOKEN: "your_access_token_here"
38+
39+
# 🛡️ Optional: Encryption key (auto-generated if not provided)
40+
# ENCRYPTION_KEY: "your_base64_encryption_key_here"
41+
42+
# 🌍 Optional: Timezone for exports
43+
TZ: "UTC"
44+
45+
# 📝 Optional: Logging level
46+
EXPORT_TRAKT_LOGGING_LEVEL: "info"
47+
48+
# 🔒 Security settings (recommended for production)
49+
EXPORT_TRAKT_SECURITY_ENABLED: "true"
50+
EXPORT_TRAKT_SECURITY_KEYRING_BACKEND: "env"
51+
EXPORT_TRAKT_SECURITY_AUDIT_LOGGING: "true"
52+
EXPORT_TRAKT_SECURITY_REQUIRE_HTTPS: "true"
53+
54+
# Persistent volumes
55+
volumes:
56+
# Configuration files (auto-created if not present)
57+
- ./config:/app/config
58+
59+
# Log files
60+
- ./logs:/app/logs
61+
62+
# Export output files
63+
- ./exports:/app/exports
64+
65+
# Optional: Mount custom performance.toml
66+
# - ./custom-performance.toml:/app/config/performance.toml:ro
67+
68+
# Resource limits (adjust based on your needs)
69+
deploy:
70+
resources:
71+
limits:
72+
memory: 512M
73+
cpus: "1.0"
74+
reservations:
75+
memory: 256M
76+
cpus: "0.5"
77+
78+
# Restart policy
79+
restart: unless-stopped
80+
81+
# Network mode (optional)
82+
# network_mode: "bridge"
83+
84+
# Optional: Expose profiling port for monitoring
85+
# ports:
86+
# - "6060:6060" # pprof profiling endpoint
87+
88+
# Health check (optional)
89+
healthcheck:
90+
test: ["CMD", "/app/export-trakt", "version"]
91+
interval: 30s
92+
timeout: 10s
93+
retries: 3
94+
start_period: 40s
95+
96+
# User (runs as non-root)
97+
user: "65532:65532" # appuser:appgroup
98+
99+
# Security options
100+
security_opt:
101+
- no-new-privileges:true
102+
read_only: true
103+
tmpfs:
104+
- /tmp:noexec,nosuid,size=100m
105+
106+
# Command to run (examples)
107+
# Default: Shows help
108+
command: ["--help"]
109+
110+
# Uncomment one of these to run specific exports:
111+
# command: ["export", "--type", "movies", "--output", "/app/exports"]
112+
# command: ["export", "--type", "shows", "--output", "/app/exports"]
113+
# command: ["export", "--type", "all", "--output", "/app/exports"]
114+
# ═══════════════════════════════════════════════════════════════════════════════
115+
# VOLUMES
116+
# ═══════════════════════════════════════════════════════════════════════════════
117+
118+
# Optional: Use named volumes instead of bind mounts
119+
# volumes:
120+
# export_trakt_config:
121+
# driver: local
122+
# export_trakt_logs:
123+
# driver: local
124+
# export_trakt_exports:
125+
# driver: local
126+
127+
# To use named volumes, replace the volumes section above with:
128+
# volumes:
129+
# - export_trakt_config:/app/config
130+
# - export_trakt_logs:/app/logs
131+
# - export_trakt_exports:/app/exports
132+
133+
# ═══════════════════════════════════════════════════════════════════════════════
134+
# NETWORKS
135+
# ═══════════════════════════════════════════════════════════════════════════════
136+
137+
# Optional: Custom network configuration
138+
# networks:
139+
# export_trakt_network:
140+
# driver: bridge
141+
# ipam:
142+
# config:
143+
# - subnet: 172.20.0.0/16
144+
145+
# ═══════════════════════════════════════════════════════════════════════════════
146+
# USAGE EXAMPLES
147+
# ═══════════════════════════════════════════════════════════════════════════════
148+
#
149+
# 🚀 Quick Start:
150+
# 1. Set your Trakt credentials in the environment section
151+
# 2. Run: docker-compose up
152+
# 3. Configuration files will be auto-created in ./config/
153+
# 4. Exports will be saved to ./exports/
154+
#
155+
# 🔧 Configuration:
156+
# - Edit ./config/config.toml for main settings
157+
# - Edit ./config/performance.toml for performance tuning (auto-created)
158+
# - View logs in ./logs/
159+
#
160+
# 📊 Export Commands:
161+
# docker-compose run --rm export-trakt export --type movies
162+
# docker-compose run --rm export-trakt export --type shows
163+
# docker-compose run --rm export-trakt export --type all
164+
#
165+
# 🔍 Monitoring:
166+
# docker-compose logs -f export-trakt
167+
# docker-compose exec export-trakt /app/export-trakt status
168+
#
169+
# 🛠️ Development:
170+
# # Enable profiling
171+
# # Uncomment ports section and set EXPORT_TRAKT_MONITORING_PROFILING_PORT=6060
172+
# # Access profiling at http://localhost:6060/debug/pprof/
173+
#
174+
# 🧹 Cleanup:
175+
# docker-compose down
176+
# docker-compose down -v # Also removes volumes
177+
#
178+
# ═══════════════════════════════════════════════════════════════════════════════

0 commit comments

Comments
 (0)