Skip to content

Commit 40b48d0

Browse files
authored
Merge pull request #15 from Nezreka/headless
Headless compatibility
2 parents d9e981c + 315f122 commit 40b48d0

23 files changed

+33591
-9952
lines changed

.dockerignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Docker ignore file for SoulSync WebUI
2+
3+
# Git
4+
.git
5+
.gitignore
6+
.gitattributes
7+
8+
# IDE and editor files
9+
.vscode/
10+
.idea/
11+
*.swp
12+
*.swo
13+
*~
14+
15+
# Python
16+
__pycache__/
17+
*.py[cod]
18+
*$py.class
19+
*.so
20+
.Python
21+
*.egg-info/
22+
dist/
23+
build/
24+
25+
# Virtual environments
26+
venv/
27+
env/
28+
ENV/
29+
30+
# Data directories (will be mounted as volumes)
31+
logs/*
32+
!logs/.gitkeep
33+
database/*.db
34+
database/*.db-shm
35+
database/*.db-wal
36+
config/config.json
37+
downloads/*
38+
!downloads/.gitkeep
39+
Transfer/*
40+
!Transfer/.gitkeep
41+
Storage/*
42+
cache/*
43+
Stream/*
44+
Incomplete/*
45+
46+
# Temporary files
47+
artist_bubble_snapshots.json
48+
.spotify_cache
49+
50+
# Documentation
51+
*.md
52+
README.md
53+
headless.md
54+
multi-server-database-plan.md
55+
server-source.md
56+
plans.md
57+
58+
# GUI-specific files
59+
main.py
60+
ui/
61+
requirements.txt
62+
63+
# OS generated files
64+
.DS_Store
65+
.DS_Store?
66+
._*
67+
.Spotlight-V100
68+
.Trashes
69+
ehthumbs.db
70+
Thumbs.db

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SoulSync WebUI Dockerfile
2+
# Multi-architecture support for AMD64 and ARM64
3+
4+
FROM python:3.11-slim
5+
6+
# Set working directory
7+
WORKDIR /app
8+
9+
# Install system dependencies
10+
RUN apt-get update && apt-get install -y \
11+
gcc \
12+
libc6-dev \
13+
libffi-dev \
14+
libssl-dev \
15+
curl \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# Create non-root user for security
19+
RUN useradd --create-home --shell /bin/bash --uid 1000 soulsync
20+
21+
# Copy requirements and install Python dependencies
22+
COPY requirements-webui.txt .
23+
RUN pip install --no-cache-dir --upgrade pip && \
24+
pip install --no-cache-dir -r requirements-webui.txt
25+
26+
# Copy application code
27+
COPY . .
28+
29+
# Create necessary directories with proper permissions
30+
RUN mkdir -p /app/config /app/database /app/logs /app/downloads /app/Transfer && \
31+
chown -R soulsync:soulsync /app
32+
33+
# Create volume mount points
34+
VOLUME ["/app/config", "/app/database", "/app/logs", "/app/downloads", "/app/Transfer"]
35+
36+
# Switch to non-root user
37+
USER soulsync
38+
39+
# Expose port
40+
EXPOSE 8008
41+
42+
# Health check
43+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
44+
CMD curl -f http://localhost:8008/ || exit 1
45+
46+
# Set environment variables
47+
ENV PYTHONPATH=/app
48+
ENV FLASK_APP=web_server.py
49+
ENV FLASK_ENV=production
50+
51+
# Run the web server
52+
CMD ["python", "web_server.py"]

README-Docker.md

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# SoulSync WebUI - Docker Deployment Guide
2+
3+
## 🐳 Quick Start
4+
5+
### Prerequisites
6+
- Docker Engine 20.10+
7+
- Docker Compose 1.29+
8+
- At least 2GB RAM and 10GB free disk space
9+
10+
### 1. Setup
11+
```bash
12+
# Clone or download the repository
13+
git clone <your-repo-url>
14+
cd newmusic
15+
16+
# Run setup script
17+
chmod +x docker-setup.sh
18+
./docker-setup.sh
19+
```
20+
21+
### 2. Configure
22+
Edit `config/config.json` with your API keys and server settings:
23+
```json
24+
{
25+
"spotify": {
26+
"client_id": "your_spotify_client_id",
27+
"client_secret": "your_spotify_client_secret"
28+
},
29+
"plex": {
30+
"url": "http://your-plex-server:32400",
31+
"token": "your_plex_token"
32+
}
33+
}
34+
```
35+
36+
### 3. Deploy
37+
```bash
38+
# Start SoulSync
39+
docker-compose up -d
40+
41+
# View logs
42+
docker-compose logs -f
43+
44+
# Access the web interface
45+
open http://localhost:8008
46+
```
47+
48+
## 📁 Volume Mounts
49+
50+
SoulSync requires persistent storage for:
51+
52+
- **`./config`**`/app/config` - Configuration files
53+
- **`./database`**`/app/database` - SQLite database files
54+
- **`./logs`**`/app/logs` - Application logs
55+
- **`./downloads`**`/app/downloads` - Downloaded music files
56+
- **`./Transfer`**`/app/Transfer` - Processed/matched music files
57+
58+
## 🔧 Configuration Options
59+
60+
### Environment Variables
61+
```yaml
62+
environment:
63+
- FLASK_ENV=production # Flask environment
64+
- PYTHONPATH=/app # Python path
65+
- SOULSYNC_CONFIG_PATH=/app/config/config.json # Config file location
66+
- TZ=America/New_York # Timezone
67+
```
68+
69+
### Port Configuration
70+
Default port is `8008`. To change:
71+
```yaml
72+
ports:
73+
- "9999:8008" # Access on port 9999
74+
```
75+
76+
### Resource Limits
77+
Adjust based on your system:
78+
```yaml
79+
deploy:
80+
resources:
81+
limits:
82+
cpus: '4.0' # Max CPU cores
83+
memory: 4G # Max RAM
84+
reservations:
85+
cpus: '1.0' # Minimum CPU
86+
memory: 1G # Minimum RAM
87+
```
88+
89+
## 🚀 Advanced Setup
90+
91+
### Multi-Architecture Support
92+
The Docker image supports both AMD64 and ARM64:
93+
```bash
94+
# Build for specific architecture
95+
docker buildx build --platform linux/amd64,linux/arm64 -t soulsync-webui .
96+
```
97+
98+
### Custom Network
99+
For integration with other containers:
100+
```yaml
101+
networks:
102+
media:
103+
external: true
104+
```
105+
106+
### External Services
107+
Connect to external Plex/Jellyfin servers:
108+
```yaml
109+
extra_hosts:
110+
- "plex.local:192.168.1.100"
111+
- "jellyfin.local:192.168.1.101"
112+
```
113+
114+
## 🔍 Troubleshooting
115+
116+
### Check Container Status
117+
```bash
118+
docker-compose ps
119+
docker-compose logs soulsync
120+
```
121+
122+
### Common Issues
123+
124+
**Permission Denied**
125+
```bash
126+
sudo chown -R 1000:1000 config database logs downloads Transfer
127+
```
128+
129+
**Port Already in Use**
130+
```bash
131+
# Check what's using port 8888
132+
sudo lsof -i :8888
133+
# Change port in docker-compose.yml
134+
```
135+
136+
**Out of Memory**
137+
```bash
138+
# Increase memory limits in docker-compose.yml
139+
# Or free up system memory
140+
```
141+
142+
### Health Check
143+
The container includes health checks:
144+
```bash
145+
docker inspect --format='{{.State.Health.Status}}' soulsync-webui
146+
```
147+
148+
## 📊 Monitoring
149+
150+
### View Real-time Logs
151+
```bash
152+
docker-compose logs -f --tail=100
153+
```
154+
155+
### Container Stats
156+
```bash
157+
docker stats soulsync-webui
158+
```
159+
160+
### Database Size
161+
```bash
162+
du -sh database/
163+
```
164+
165+
## 🔄 Updates
166+
167+
### Pull Latest Image
168+
```bash
169+
docker-compose pull
170+
docker-compose up -d
171+
```
172+
173+
### Backup Before Update
174+
```bash
175+
# Backup data
176+
tar -czf soulsync-backup-$(date +%Y%m%d).tar.gz config/ database/ logs/
177+
178+
# Update
179+
docker-compose pull && docker-compose up -d
180+
```
181+
182+
## 🛠️ Development
183+
184+
### Build Local Image
185+
```bash
186+
docker build -t soulsync-webui .
187+
```
188+
189+
### Development Mode
190+
```yaml
191+
# In docker-compose.yml
192+
environment:
193+
- FLASK_ENV=development
194+
volumes:
195+
- .:/app # Mount source code for live reload
196+
```
197+
198+
## 🔐 Security
199+
200+
### Non-Root User
201+
The container runs as user `soulsync` (UID 1000) for security.
202+
203+
### Network Security
204+
```yaml
205+
# Restrict to localhost only
206+
ports:
207+
- "127.0.0.1:8888:8888"
208+
```
209+
210+
### Firewall
211+
```bash
212+
# Allow only local access
213+
sudo ufw allow from 192.168.1.0/24 to any port 8888
214+
```
215+
216+
## 📋 Complete Example
217+
218+
Here's a complete `docker-compose.yml` for production:
219+
220+
```yaml
221+
version: '3.8'
222+
223+
services:
224+
soulsync:
225+
build: .
226+
container_name: soulsync-webui
227+
restart: unless-stopped
228+
ports:
229+
- "8888:8888"
230+
volumes:
231+
- ./config:/app/config
232+
- ./database:/app/database
233+
- ./logs:/app/logs
234+
- ./downloads:/app/downloads
235+
- ./Transfer:/app/Transfer
236+
- /mnt/music:/music:ro # Your music library
237+
environment:
238+
- FLASK_ENV=production
239+
- TZ=America/New_York
240+
- PYTHONPATH=/app
241+
deploy:
242+
resources:
243+
limits:
244+
cpus: '2.0'
245+
memory: 2G
246+
reservations:
247+
cpus: '0.5'
248+
memory: 512M
249+
healthcheck:
250+
test: ["CMD", "curl", "-f", "http://localhost:8888/"]
251+
interval: 30s
252+
timeout: 10s
253+
retries: 3
254+
start_period: 60s
255+
logging:
256+
driver: "json-file"
257+
options:
258+
max-size: "10m"
259+
max-file: "3"
260+
```
261+
262+
## 🎯 Production Checklist
263+
264+
- [ ] Configure proper API keys in `config/config.json`
265+
- [ ] Set appropriate resource limits
266+
- [ ] Configure proper volume mounts
267+
- [ ] Set up log rotation
268+
- [ ] Configure firewall rules
269+
- [ ] Set up backup strategy
270+
- [ ] Test health checks
271+
- [ ] Verify external service connectivity

0 commit comments

Comments
 (0)