Complete setup guide for deploying a production-ready MusicBrainz mirror.
Important: This local folder must be placed inside the official musicbrainz-docker repository.
- Overview
- Hardware Requirements
- Quick Start
- Server Preparation
- Configuration
- Deployment
- Monitoring & Maintenance
- Troubleshooting
- Backup & Recovery
- Updating
- Full MusicBrainz Mirror: Complete read-only replica of the MusicBrainz database
- HTTPS with Cloudflare: Origin Certificates valid for 15 years
- High Performance: Optimized for 64GB RAM / 16-core / NVMe storage
- Security Hardened: UFW firewall, restricted ports, HSTS enabled
- Gzip Compression: Automatic compression for text-based responses
- Automatic Cache Warming: PostgreSQL pg_prewarm for fast restarts
Internet → Cloudflare
→ Origin Server (ports 80, 443)
→ nginx (HTTPS, gzip, rate limiting)
→ MusicBrainz App (40 workers)
→ PostgreSQL 16 (8GB shared_buffers)
→ Solr Search (12GB heap)
- Domain:
musicbrainz-mirror.music-assistant.io - Server: Ubuntu with Docker
- CPU: 16 cores
- RAM: 64GB
- Storage: 1TB NVMe RAID 1
- Network: 1Gbps
curl -fsSL https://raw.githubusercontent.com/OpenHomeFoundation/musicbrainz-docker-local/main/bootstrap.sh | bash
# OR
wget -qO- https://raw.githubusercontent.com/OpenHomeFoundation/musicbrainz-docker-local/main/bootstrap.sh | bashgit clone https://github.com/metabrainz/musicbrainz-docker.git
cd musicbrainz-dockergit clone https://github.com/OpenHomeFoundation/musicbrainz-docker-local local- Go to Cloudflare Dashboard → SSL/TLS → Origin Server
- Click Create Certificate
- Select "Generate private key and CSR with Cloudflare"
- Add your domain(s)
- Choose validity
- Copy the Origin Certificate and Private Key and save them as
cert.pemandkey.pem.
Base64 encode your certificates:
# Linux:
cat cert.pem | base64 -w0
cat key.pem | base64 -w0
# macOS:
cat cert.pem | base64 | tr -d '\n'
cat key.pem | base64 | tr -d '\n'Edit .env in the musicbrainz-docker root:
MUSICBRAINZ_DOMAIN=musicbrainz-mirror.music-assistant.io
MUSICBRAINZ_WEB_SERVER_HOST=musicbrainz-mirror.music-assistant.io
MUSICBRAINZ_WEB_SERVER_PORT=443
# SSL Certificate (Base64 encoded - single line each)
SSL_CERTIFICATE_BASE64=LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0t...
SSL_CERTIFICATE_KEY_BASE64=LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0t...
# Enable basic compose fules -- follow original readme procedure to enable replication cron (which updates this line)
COMPOSE_FILE=docker-compose.yml:local/docker-compose.ohf.ymlIn Cloudflare Dashboard → SSL/TLS:
- Set SSL mode to Full (strict)
docker compose up -dExecute install.sh to prepare the server(Only ubuntu supported):
- Go to Cloudflare Dashboard → SSL/TLS → Origin Server
- Click Create Certificate
- Select "Generate private key and CSR with Cloudflare"
- Add your domain(s)
- Choose validity: 15 years
- Copy the Origin Certificate and Private Key
Save them as cert.pem and key.pem.
Base64 encode your certificates (required for Docker Compose):
# On Linux:
cat cert.pem | base64 -w0 > cert.b64
cat key.pem | base64 -w0 > key.b64
# On macOS:
cat cert.pem | base64 | tr -d '\n' > cert.b64
cat key.pem | base64 | tr -d '\n' > key.b64Then create your .env file:
cat > .env << 'EOF'
# Domain Configuration
MUSICBRAINZ_DOMAIN=musicbrainz-mirror.music-assistant.io
MUSICBRAINZ_WEB_SERVER_HOST=musicbrainz-mirror.music-assistant.io
MUSICBRAINZ_WEB_SERVER_PORT=443
# SSL Certificate (Base64 encoded - single line each)
# (Optional) if ommited, the default self-signed cert will be used
SSL_CERTIFICATE_BASE64=<paste contents of cert.b64>
SSL_CERTIFICATE_KEY_BASE64=<paste contents of key.b64>
# Compose Configuration
COMPOSE_FILE=docker-compose.yml:local/docker-compose.ohf.yml
EOF| File | Purpose |
|---|---|
.env |
Domain, certificates, compose chain |
local/docker-compose.ohf.yml |
PostgreSQL, Solr, Redis, nginx optimizations |
local/config/nginx/nginx.conf.template |
Nginx configuration template |
cd ~/musicbrainz-docker
# Start all services
docker compose up -d
# Monitor startup
docker compose ps
docker compose logs -f nginx
docker compose logs -f musicbrainz# Check certificate is loaded
docker exec nginx cat /etc/nginx/ssl/fullchain.pem | openssl x509 -noout -dates
# Test HTTPS
curl -k https://localhost/health# Verify DNS points to Cloudflare
dig +short musicbrainz-mirror.music-assistant.io# View all containers
docker compose ps
# Check resource usage
docker stats
# View logs
docker compose logs -f nginx
docker compose logs -f musicbrainz
docker compose logs -f db# Check database size
docker compose exec db psql -U musicbrainz musicbrainz_db -c \
"SELECT pg_size_pretty(pg_database_size(current_database()));"
# Check replication status
docker compose exec db psql -U musicbrainz musicbrainz_db -c \
"SELECT * FROM replication_control;"
# View table sizes
docker compose exec db psql -U musicbrainz musicbrainz_db -c \
"SELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS size
FROM pg_tables WHERE schemaname = 'musicbrainz' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;"# System memory
free -h
# Container memory
docker stats --no-stream --format 'table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}'Cause: MusicBrainz container not ready or crashed
docker compose ps
docker compose logs musicbrainz --tail 50
docker compose restart musicbrainzCause: Certificate not written or invalid
# Check certificate exists
docker exec nginx ls -la /etc/nginx/ssl/
# Check certificate content
docker exec nginx cat /etc/nginx/ssl/fullchain.pem | openssl x509 -noout -text
# Check nginx logs
docker compose logs nginxCause: MUSICBRAINZ_WEB_SERVER_PORT not set to 443
# Verify .env
grep WEB_SERVER_PORT .env
# Recreate container
docker compose up -d --force-recreate musicbrainz# Check PostgreSQL logs
docker compose logs db
# Verify database is running
docker compose exec db psql -U musicbrainz -c "SELECT version();"
# Check connections
docker compose exec db psql -U musicbrainz -c "SELECT count(*) FROM pg_stat_activity;"# nginx logs
docker compose logs nginx
# MusicBrainz application logs
docker compose logs musicbrainz
# PostgreSQL logs
docker compose logs db
# Solr search logs
docker compose logs search
# All logs
docker compose logs --tail=100 -fdocker compose exec db pg_dump -U musicbrainz musicbrainz_db | \
gzip > musicbrainz-db-backup-$(date +%Y%m%d).sql.gzgunzip -c musicbrainz-db-backup-YYYYMMDD.sql.gz | \
docker compose exec -T db psql -U musicbrainz musicbrainz_dbcd ~/musicbrainz-docker
git pull origin main
# Pull latest images
docker compose pull
# Recreate containers
docker compose up -d
# Clean up old images
docker image prune -fLast Updated: 2026-02-03 Maintained By: Open Home Foundation