123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
# Docker Installation Guide
## Overview
Docker installation is the recommended method for running 5q12's Indexer. It provides complete environment isolation, automatic dependency management, and works consistently across different operating systems.
### Why Docker?
- **Zero host dependencies** - No need to install PHP, web servers, or configure anything
- **Consistent environment** - Works the same on Windows, macOS, and Linux
- **Easy updates** - Pull new images and restart containers
- **Isolation** - Doesn't interfere with existing web servers or PHP installations
- **Production ready** - Built-in process management and health checks
## Prerequisites
- **Docker** (version 20.0+)
- **Docker Compose** (version 2.0+)
- **512MB RAM** minimum (1GB+ recommended)
- **100MB disk space** for image and data
### Install Docker
**Ubuntu/Debian:**
```bash
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
```
**Windows/macOS:**
Download Docker Desktop from [docker.com](https://www.docker.com/products/docker-desktop/)
## Quick Start
### Step 1: Create Docker Compose Configuration
Create a `docker-compose.yml` file:
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
container_name: 5q12-indexer
restart: unless-stopped
ports:
- "5012:5012" # Access the indexer on port 5012
environment:
- TZ=Etc/UTC # Set your timezone (optional)
volumes:
# Configuration directory - stores config.json and config-reference.txt
- /your/host/config:/config
# Application directory - stores icons, caches, and runtime files
- /your/host/app:/app
# Files directory - mount your content here to index
- /your/host/files:/files
```
### Step 2: Create Host Directories
```bash
# Create directories for persistent data
mkdir -p /your/host/{config,app,files}
# Set appropriate permissions
sudo chown -R 82:82 /your/host/config /your/host/app
chmod -R 755 /your/host/files
```
### Step 3: Start the Container
```bash
# Start the indexer
docker compose up -d
# Check status
docker compose logs -f 5q12-indexer
```
### Step 4: Access the Indexer
Open your browser to: `http://localhost:5012`
## Volume Architecture
The indexer uses a **clean separation architecture** with three distinct mount points:
```
/config/ # Configuration files only
├── config.json # Settings (source of truth, editable)
└── config-reference.txt # Documentation (refreshed on restart)
/app/ # Application runtime files only
├── icons/ # File type icons (persisted)
├── favicon/ # Favicon files
├── local_api/ # API endpoints
├── php/ # PHP class files
├── zip_cache/ # Temporary ZIP downloads
└── index_cache/ # Performance cache
/files/ # Your content to browse
└── (your files and folders)
```
### Internal Symlink Structure
The application directory (`/www/indexer/.indexer_files/`) contains individual symlinks to both `/config` and `/app`:
```
/www/indexer/.indexer_files/ (directory with individual symlinks)
├── config.json → /config/config.json
├── config-reference.txt → /config/config-reference.txt
├── icons → /app/icons
├── favicon → /app/favicon
├── local_api → /app/local_api
├── php → /app/php
├── zip_cache → /app/zip_cache
└── index_cache → /app/index_cache
```
**Benefits:**
- Config files only in `/config` (no duplication)
- App files only in `/app` (no config mixing)
- Both can be mounted externally without conflicts
- Config changes don't require container restart
- Reference documentation always current
## Configuration Examples
### Minimal Setup (Config + Files Only)
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
container_name: file-server
restart: unless-stopped
ports:
- "8080:5012"
environment:
- TZ=America/New_York
volumes:
- ./config:/config
- ./public-files:/files
```
Without mounting `/app`, icons and caches are generated inside the container and lost on restart (but automatically regenerated).
### Recommended Setup (All Volumes)
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
container_name: file-server
restart: unless-stopped
ports:
- "8080:5012"
environment:
- TZ=America/New_York
volumes:
- ./config:/config
- ./app:/app
- ./public-files:/files
```
With `/app` mounted, icons and caches persist across restarts for better performance.
### Media Server with Multiple Mounts
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
container_name: media-indexer
restart: unless-stopped
ports:
- "5012:5012"
environment:
- TZ=Europe/London
- INDEXER_CACHE_TYPE=sqlite
- INDEXER_ICON_TYPE=default
- INDEXER_INDEX_FILETYPE_MP4=true
- INDEXER_VIEW_FILETYPE_MP4=true
volumes:
- ./config:/config
- ./app:/app
- ./files:/files
# Mount different content types
- /mnt/movies:/files/movies:ro
- /mnt/music:/files/music:ro
- /mnt/documents:/files/documents:ro
- /home/user/downloads:/files/downloads
```
### Production Setup with Resource Limits
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
container_name: 5q12-indexer-prod
restart: unless-stopped
ports:
- "5012:5012"
environment:
- TZ=Etc/UTC
- INDEXER_ACCESS_URL=https://files.example.com
- INDEXER_CACHE_TYPE=sqlite
- INDEXER_ICON_TYPE=default
- INDEXER_INDEX_HIDDEN=false
- INDEXER_DENY_LIST=.env,.git,admin,logs
volumes:
- /opt/indexer/config:/config
- /opt/indexer/app:/app
- /srv/public:/files:ro
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
security_opt:
- no-new-privileges:true
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
```
## Volume Configuration
### Required Volumes
| Host Path | Container Path | Purpose | Required | Contents |
|-----------|----------------|---------|----------|----------|
| `./config` | `/config` | Configuration files | Yes | config.json, config-reference.txt |
| `./app` | `/app` | Application runtime | Recommended | Icons, caches, runtime files |
| `./files` | `/files` | Content to browse | Yes | Your files and folders |
### Volume Details
**Configuration Volume (`/config`):**
- `config.json` - Settings file (editable, source of truth)
- `config-reference.txt` - Documentation (refreshed on each restart)
- Changes to config.json apply immediately without restart
**Application Volume (`/app`):**
- `icons/` - File type icons (persisted across restarts)
- `favicon/` - Favicon files
- `local_api/` - API endpoint files
- `php/` - PHP class files
- `zip_cache/` - Temporary ZIP files for folder downloads
- `index_cache/` - Directory listing cache for performance
**Files Volume (`/files`):**
- Root directory for browsing
- Mount your content here
- Can include subdirectories
- Supports read-only mounts (`:ro`)
### Permission Requirements
The container runs as `www-data` (UID 82, GID 82). Ensure host directories are accessible:
```bash
# Option 1: Match container user
sudo chown -R 82:82 /path/to/config /path/to/app
# Option 2: Use permissive permissions
chmod -R 755 /path/to/config /path/to/app /path/to/files
```
## Environment Variables
### Main Configuration
| Variable | Default | Description |
|----------|---------|-------------|
| `TZ` | `Etc/UTC` | Container timezone |
| `INDEXER_ACCESS_URL` | `""` | Base URL for absolute links |
| `INDEXER_CACHE_TYPE` | `sqlite` | Cache type (`sqlite` or `json`) |
| `INDEXER_ICON_TYPE` | `default` | Icon display type |
| `INDEXER_INDEX_ALL` | `false` | Index all files |
| `INDEXER_INDEX_HIDDEN` | `false` | Index hidden files/folders |
### Download Controls
| Variable | Default | Description |
|----------|---------|-------------|
| `INDEXER_DISABLE_FILE_DOWNLOADS` | `false` | Disable file downloads |
| `INDEXER_DISABLE_FOLDER_DOWNLOADS` | `false` | Disable folder downloads |
| `INDEXER_MAX_DOWNLOAD_SIZE_FILE` | `2048 MB` | Max file download size |
| `INDEXER_MAX_DOWNLOAD_SIZE_FOLDER` | `2048 MB` | Max folder download size |
### Access Controls
| Variable | Default | Description |
|----------|---------|-------------|
| `INDEXER_DENY_LIST` | `""` | Comma-separated deny patterns |
| `INDEXER_ALLOW_LIST` | `""` | Comma-separated allow patterns |
### File Type Configuration
Configure any file type using these patterns:
- `INDEXER_INDEX_FILETYPE_{TYPE}=true/false` - Show in listings
- `INDEXER_VIEW_FILETYPE_{TYPE}=true/false` - Allow viewing
```yaml
environment:
- INDEXER_VIEW_FILETYPE_PHP=false
- INDEXER_INDEX_FILETYPE_LOG=false
- INDEXER_VIEW_FILETYPE_MD=true
```
**Timezone Examples:**
- `America/New_York`
- `Europe/London`
- `Asia/Tokyo`
- `Australia/Sydney`
## Port Configuration
**Default Port:** Container exposes port 5012
**Custom Port Examples:**
```yaml
ports:
- "8080:5012" # Access via localhost:8080
- "80:5012" # Access via localhost (requires sudo/root)
- "443:5012" # HTTPS setup (requires reverse proxy)
```
## Management Commands
### Container Management
```bash
# Start containers
docker compose up -d
# Stop containers
docker compose down
# Restart containers
docker compose restart
# View logs
docker compose logs -f
# Update to latest image
docker compose pull
docker compose up -d
```
### Maintenance
```bash
# Access container shell
docker exec -it 5q12-indexer sh
# Check container status
docker ps
# View resource usage
docker stats 5q12-indexer
# Clean up old images
docker image prune
# Verify symlink structure
docker exec 5q12-indexer ls -la /www/indexer/.indexer_files/
```
### Configuration Management
```bash
# View current config
docker exec 5q12-indexer cat /config/config.json
# View reference documentation
docker exec 5q12-indexer cat /config/config-reference.txt
# Edit config from host (if mounted)
vim ./config/config.json
# Changes apply immediately without restart
```
## Updates and Backups
### Updating
```bash
# Pull latest image
docker compose pull 5q12/5q12-indexer:latest
# Recreate container with new image
docker compose up -d
# Clean up old images
docker image prune
```
### Backup Configuration
```bash
# Backup config directory
tar -czf indexer-config-$(date +%Y%m%d).tar.gz /path/to/config
# Backup app directory (includes caches and icons)
tar -czf indexer-app-$(date +%Y%m%d).tar.gz /path/to/app
# Backup docker compose configuration
cp docker-compose.yml docker-compose.yml.backup
```
### Version Pinning
Use specific versions for production stability:
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:1.1.19 # Pin to specific version
```
## SSL/HTTPS Setup
### Using Reverse Proxy (Recommended)
**Nginx Proxy:**
```nginx
server {
listen 443 ssl;
server_name files.yourdomain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:5012;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
**Traefik Example:**
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
labels:
- "traefik.enable=true"
- "traefik.http.routers.indexer.rule=Host(`files.yourdomain.com`)"
- "traefik.http.routers.indexer.tls.certresolver=letsencrypt"
```
## Troubleshooting
### Container Won't Start
```bash
# Check logs for errors
docker compose logs 5q12-indexer
# Check if ports are available
netstat -tlnp | grep :5012
# Verify volume permissions
ls -la /path/to/config /path/to/app /path/to/files
```
### Permission Issues
```bash
# Fix ownership
sudo chown -R 82:82 /path/to/config /path/to/app
# Or use permissive mode
chmod -R 755 /path/to/config /path/to/app /path/to/files
```
### Configuration Issues
```bash
# Check if config exists
docker exec 5q12-indexer cat /config/config.json
# Verify symlinks are correct
docker exec 5q12-indexer ls -la /www/indexer/.indexer_files/
# Test config edit (should work without restart)
echo '{"main":{"cache_type":"json"}}' > ./config/config.json
# Refresh browser - changes should apply immediately
```
### Performance Issues
```bash
# Check resource usage
docker stats 5q12-indexer
# Increase memory limits in compose file
deploy:
resources:
limits:
memory: 1G
# Clear caches (if /app is mounted)
rm -rf ./app/zip_cache/* ./app/index_cache/*
```
### Network Issues
```bash
# Test internal connectivity
docker exec 5q12-indexer curl -I http://localhost:5012
# Check host networking
curl -I http://localhost:5012
```
## Security Considerations
### Container Security
- Container runs as non-root user (www-data)
- No privileged access required
- Clean file separation prevents config conflicts
- Resource limits prevent abuse
- Read-only filesystem where possible
### Network Security
- Only expose necessary ports
- Use reverse proxy for SSL termination
- Consider firewall rules for production
### File Access Security
- Use read-only mounts (`:ro`) for sensitive content
- Limit container access to specific directories
- Regular security updates via image updates
- Config files isolated in dedicated volume
## Production Deployment
### Multi-Container Setup
```yaml
services:
indexer:
image: 5q12/5q12-indexer:latest
restart: unless-stopped
volumes:
- indexer-config:/config
- indexer-app:/app
- /srv/public:/files:ro
networks:
- web
nginx:
image: nginx:alpine
restart: unless-stopped
ports:
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
networks:
- web
depends_on:
- indexer
volumes:
indexer-config:
indexer-app:
networks:
web:
```
### Health Checks
```yaml
services:
5q12-indexer:
image: 5q12/5q12-indexer:latest
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5012"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
```
## Performance Tips
- **Mount `/app`** to persist caches and icons across restarts
- **Use SQLite cache** (`INDEXER_CACHE_TYPE=sqlite`) for better performance
- **Disable icons** (`INDEXER_ICON_TYPE=disabled`) if not needed
- **Mount `/files` as read-only** (`:ro`) when possible
- **Use SSD storage** for `/app` directory for faster cache access
---
**Next Steps:**
- [Configuration Guide](configuration.md) - Customize indexer settings
- [Security Guide](security.md) - Production security setup
- [User Guide](user-guide.md) - Using the interface