# Docker Deployment Guide ## Quick Start ### 1. Build the Docker image ```bash docker build -t carplay-audio-server . ``` ### 2. Run with Docker Compose (Recommended) Edit `docker-compose.yml` and update the music library path: ```yaml volumes: - /path/to/your/music:/data/music:ro # Change this! ``` Then start: ```bash docker-compose up -d ``` ### 3. Run with Docker directly ```bash docker run -d \ --name carplay-audio \ -p 4000:4000 \ -v /path/to/your/music:/data/music:ro \ -v $(pwd)/data/artwork:/app/artwork \ -v $(pwd)/data/database:/app \ carplay-audio-server ``` ## Initial Setup ### Scan your library ```bash # Using docker-compose docker-compose exec carplay-audio npm run scan # Using docker docker exec carplay-audio npm run scan ``` ### Access the admin panel Open your browser to: `http://localhost:4000` ### Configure Amperfy - **Server URL**: `http://YOUR-SERVER-IP:4000` - **Username**: `admin` - **Password**: `admin` ## Configuration ### Environment Variables - `PORT` - Server port (default: 4000) - `NODE_ENV` - Environment (production/development) - `SCAN_ON_START` - Set to "true" to scan library on container start ### Volumes - `/data/music` - Your music library (read-only) - `/app/artwork` - Extracted album artwork - `/app/audio_server.db` - SQLite database - `/app/config.json` - Server configuration ## Management ### View logs ```bash docker-compose logs -f carplay-audio ``` ### Restart server ```bash docker-compose restart carplay-audio ``` ### Stop server ```bash docker-compose down ``` ### Update and rebuild ```bash git pull docker-compose down docker-compose build docker-compose up -d ``` ## Behind Reverse Proxy If using nginx or Cloudflare Tunnel, configure it to proxy to `http://localhost:4000`. Example nginx config: ```nginx location / { proxy_pass http://localhost:4000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } ``` ## Troubleshooting ### Container won't start Check logs: ```bash docker-compose logs carplay-audio ``` ### Music not showing Rescan the library: ```bash docker-compose exec carplay-audio npm run scan ``` ### Permission issues Ensure the music directory is readable: ```bash chmod -R 755 /path/to/your/music ``` ## Production Deployment 1. **Change default credentials** in `src/routes/subsonic.js` 2. **Use HTTPS** via reverse proxy 3. **Set up automatic backups** of the database 4. **Monitor logs** for errors 5. **Set resource limits** in docker-compose.yml: ```yaml deploy: resources: limits: cpus: '2' memory: 1G ```