|
| 1 | +# Docker Setup for Karaoke For Jellyfin |
| 2 | + |
| 3 | +This document provides instructions for building and running the Karaoke For Jellyfin application using Docker. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### Using Docker Compose (Recommended) |
| 8 | + |
| 9 | +1. **Copy the environment file:** |
| 10 | + ```bash |
| 11 | + cp .env.local.example .env.local |
| 12 | + ``` |
| 13 | + |
| 14 | +2. **Edit `.env.local` with your configuration:** |
| 15 | + ```bash |
| 16 | + # Jellyfin Configuration |
| 17 | + JELLYFIN_SERVER_URL=http://host.docker.internal:8096 |
| 18 | + JELLYFIN_API_KEY=your_jellyfin_api_key_here |
| 19 | + JELLYFIN_USERNAME=your_jellyfin_username_here |
| 20 | + |
| 21 | + # Lyrics Configuration (adjust paths as needed) |
| 22 | + LYRICS_PATH=./lyrics |
| 23 | + JELLYFIN_MEDIA_PATH=/path/to/your/jellyfin/media |
| 24 | + |
| 25 | + # Application Configuration |
| 26 | + NEXT_PUBLIC_APP_URL=http://localhost:3000 |
| 27 | + SESSION_SECRET=your_secure_session_secret_here |
| 28 | + ``` |
| 29 | + |
| 30 | +3. **Start the application:** |
| 31 | + ```bash |
| 32 | + docker-compose up -d |
| 33 | + ``` |
| 34 | + |
| 35 | +4. **Access the application:** |
| 36 | + - Mobile interface: http://localhost:3000 |
| 37 | + - TV display: http://localhost:3000/tv |
| 38 | + |
| 39 | +### Using Docker directly |
| 40 | + |
| 41 | +1. **Build the image:** |
| 42 | + ```bash |
| 43 | + docker build -t karaoke-for-jellyfin . |
| 44 | + ``` |
| 45 | + |
| 46 | +2. **Run the container:** |
| 47 | + ```bash |
| 48 | + docker run -d \ |
| 49 | + --name karaoke-app \ |
| 50 | + -p 3000:3000 \ |
| 51 | + -e JELLYFIN_SERVER_URL=http://host.docker.internal:8096 \ |
| 52 | + -e JELLYFIN_API_KEY=your_api_key \ |
| 53 | + -e JELLYFIN_USERNAME=your_username \ |
| 54 | + -e NEXT_PUBLIC_APP_URL=http://localhost:3000 \ |
| 55 | + -e SESSION_SECRET=your_session_secret \ |
| 56 | + -v $(pwd)/lyrics:/app/lyrics:ro \ |
| 57 | + -v /path/to/jellyfin/media:/app/media:ro \ |
| 58 | + --add-host host.docker.internal:host-gateway \ |
| 59 | + karaoke-for-jellyfin |
| 60 | + ``` |
| 61 | + |
| 62 | +## Configuration |
| 63 | + |
| 64 | +### Environment Variables |
| 65 | + |
| 66 | +| Variable | Description | Default | Required | |
| 67 | +|----------|-------------|---------|----------| |
| 68 | +| `JELLYFIN_SERVER_URL` | URL to your Jellyfin server | `http://localhost:8096` | Yes | |
| 69 | +| `JELLYFIN_API_KEY` | Jellyfin API key | - | Yes | |
| 70 | +| `JELLYFIN_USERNAME` | Jellyfin username | - | Yes | |
| 71 | +| `LYRICS_PATH` | Path to lyrics folder | `/app/lyrics` | No | |
| 72 | +| `JELLYFIN_MEDIA_PATH` | Path to Jellyfin media | `/app/media` | No | |
| 73 | +| `NEXT_PUBLIC_APP_URL` | Public URL of the app | `http://localhost:3000` | No | |
| 74 | +| `SESSION_SECRET` | Secret for session management | - | Yes | |
| 75 | + |
| 76 | +### Volume Mounts |
| 77 | + |
| 78 | +- **Lyrics Directory**: Mount your lyrics folder to `/app/lyrics` (read-only) |
| 79 | +- **Media Directory**: Mount your Jellyfin media folder to `/app/media` (read-only) |
| 80 | + |
| 81 | +### Network Configuration |
| 82 | + |
| 83 | +The application needs to communicate with your Jellyfin server. There are several ways to configure this: |
| 84 | + |
| 85 | +#### Option 1: Host Gateway (Recommended) |
| 86 | +Use `host.docker.internal` in your Jellyfin URL and add the host gateway: |
| 87 | +```bash |
| 88 | +--add-host host.docker.internal:host-gateway |
| 89 | +``` |
| 90 | + |
| 91 | +#### Option 2: Host Network |
| 92 | +Use host networking to access services on localhost: |
| 93 | +```yaml |
| 94 | +network_mode: host |
| 95 | +``` |
| 96 | +
|
| 97 | +#### Option 3: External Network |
| 98 | +If Jellyfin is running in another container, use a shared network. |
| 99 | +
|
| 100 | +## Development |
| 101 | +
|
| 102 | +### Development with Docker |
| 103 | +
|
| 104 | +For development, you can mount the source code and use hot reloading: |
| 105 | +
|
| 106 | +```bash |
| 107 | +docker run -it \ |
| 108 | + --name karaoke-dev \ |
| 109 | + -p 3000:3000 \ |
| 110 | + -v $(pwd):/app \ |
| 111 | + -v /app/node_modules \ |
| 112 | + -e NODE_ENV=development \ |
| 113 | + node:18-alpine \ |
| 114 | + sh -c "cd /app && npm install && npm run dev" |
| 115 | +``` |
| 116 | + |
| 117 | +### Building for Different Architectures |
| 118 | + |
| 119 | +To build for multiple architectures (useful for deployment on different systems): |
| 120 | + |
| 121 | +```bash |
| 122 | +# Build for AMD64 and ARM64 |
| 123 | +docker buildx build --platform linux/amd64,linux/arm64 -t karaoke-for-jellyfin . |
| 124 | +``` |
| 125 | + |
| 126 | +## Troubleshooting |
| 127 | + |
| 128 | +### Common Issues |
| 129 | + |
| 130 | +1. **Cannot connect to Jellyfin server** |
| 131 | + - Ensure `JELLYFIN_SERVER_URL` is accessible from within the container |
| 132 | + - Use `host.docker.internal` instead of `localhost` if Jellyfin is on the host |
| 133 | + - Check firewall settings |
| 134 | + |
| 135 | +2. **Lyrics not loading** |
| 136 | + - Verify the lyrics directory is mounted correctly |
| 137 | + - Check file permissions (container runs as user `nextjs` with UID 1001) |
| 138 | + |
| 139 | +3. **WebSocket connection issues** |
| 140 | + - Ensure port 3000 is properly exposed |
| 141 | + - Check if reverse proxy is configured correctly for WebSocket upgrades |
| 142 | + |
| 143 | +4. **Permission denied errors** |
| 144 | + - The container runs as a non-root user (nextjs:nodejs) |
| 145 | + - Ensure mounted volumes have appropriate permissions |
| 146 | + |
| 147 | +### Logs |
| 148 | + |
| 149 | +View application logs: |
| 150 | +```bash |
| 151 | +# Docker Compose |
| 152 | +docker-compose logs -f karaoke-app |
| 153 | + |
| 154 | +# Docker directly |
| 155 | +docker logs -f karaoke-app |
| 156 | +``` |
| 157 | + |
| 158 | +### Health Check |
| 159 | + |
| 160 | +Check if the application is running: |
| 161 | +```bash |
| 162 | +curl http://localhost:3000/api/health |
| 163 | +``` |
| 164 | + |
| 165 | +## Production Deployment |
| 166 | + |
| 167 | +### Security Considerations |
| 168 | + |
| 169 | +1. **Use strong session secrets**: Generate a secure random string for `SESSION_SECRET` |
| 170 | +2. **Secure API keys**: Store Jellyfin API keys securely (consider using Docker secrets) |
| 171 | +3. **Network security**: Use proper firewall rules and consider using a reverse proxy |
| 172 | +4. **Regular updates**: Keep the Docker image updated with security patches |
| 173 | + |
| 174 | +### Performance Optimization |
| 175 | + |
| 176 | +1. **Resource limits**: Set appropriate CPU and memory limits |
| 177 | +2. **Persistent storage**: Use named volumes for better performance |
| 178 | +3. **Reverse proxy**: Use nginx or similar for SSL termination and caching |
| 179 | + |
| 180 | +### Example Production docker-compose.yml |
| 181 | + |
| 182 | +```yaml |
| 183 | +version: '3.8' |
| 184 | + |
| 185 | +services: |
| 186 | + karaoke-app: |
| 187 | + build: . |
| 188 | + restart: unless-stopped |
| 189 | + ports: |
| 190 | + - "127.0.0.1:3000:3000" # Only bind to localhost |
| 191 | + environment: |
| 192 | + - NODE_ENV=production |
| 193 | + - JELLYFIN_SERVER_URL=https://your-jellyfin-server.com |
| 194 | + - JELLYFIN_API_KEY_FILE=/run/secrets/jellyfin_api_key |
| 195 | + - SESSION_SECRET_FILE=/run/secrets/session_secret |
| 196 | + volumes: |
| 197 | + - lyrics_data:/app/lyrics:ro |
| 198 | + - media_data:/app/media:ro |
| 199 | + secrets: |
| 200 | + - jellyfin_api_key |
| 201 | + - session_secret |
| 202 | + deploy: |
| 203 | + resources: |
| 204 | + limits: |
| 205 | + memory: 512M |
| 206 | + cpus: '0.5' |
| 207 | + |
| 208 | +volumes: |
| 209 | + lyrics_data: |
| 210 | + external: true |
| 211 | + media_data: |
| 212 | + external: true |
| 213 | + |
| 214 | +secrets: |
| 215 | + jellyfin_api_key: |
| 216 | + external: true |
| 217 | + session_secret: |
| 218 | + external: true |
| 219 | +``` |
| 220 | +
|
| 221 | +## Support |
| 222 | +
|
| 223 | +If you encounter issues with the Docker setup, please check: |
| 224 | +1. Docker and Docker Compose versions |
| 225 | +2. System requirements and available resources |
| 226 | +3. Network connectivity to Jellyfin server |
| 227 | +4. File permissions for mounted volumes |
0 commit comments