Skip to content

muza-music/muza-cover-art-server

Repository files navigation

Muza Cover Art Server

A lightweight server for serving and optionally uploading cover art images.

Features

  • Secure image serving with path traversal protection
  • Optional upload endpoint
  • SSL/TLS support
  • Podman container support

Installation and Running (Local)

  1. Clone the repository:
git clone https://github.com/yaacov/muza-cover-art-server.git
cd muza-cover-art-server
  1. Create a virtual environment and install dependencies:
# Set up venv
make all
# Activate venv
source venv/bin/activate

Running the Server

Production Mode

# Run with Gunicorn
./run_server.sh

Environment variables for configuration:

  • HOST: Binding address (default: 0.0.0.0)
  • PORT: Server port (default: 5000)
  • WORKERS: Number of Gunicorn workers (default: 3)
  • IMAGES_DIR: Directory for images (default: images)
  • ALLOW_UPLOAD: Enable upload endpoint if set
  • USE_SSL: Enable SSL/TLS if set
  • CERT_FILE: Path to SSL certificate (default: certs/server.crt)
  • KEY_FILE: Path to SSL key (default: certs/server.key)

Development Mode

# Run with Flask development server
make run-dev

Local Development Options

  1. Basic server (readonly):
make run
  1. Enable upload capability:
make run-with-upload
  1. Run with SSL:
# First generate certificates
make certs

# Then run with SSL
make run-ssl
# or with uploads enabled
make run-with-upload-ssl

Usage Examples

Retrieving Images

# Get an image
curl http://localhost:5000/cover-art/album1.jpg

# Using SSL
curl https://localhost:5000/cover-art/album1.jpg --cacert certs/server.crt

Uploading Images (when enabled)

# Upload an image
curl -X POST -F "file=@/path/to/local/image.jpg" http://localhost:5000/cover-art

# Upload with SSL
curl -X POST -F "file=@/path/to/local/image.jpg" \
  https://localhost:5000/cover-art \
  --cacert certs/server.crt

Container Support

Building and Running with Containers

  1. Build the container:
make container-build
# or
podman build -t quay.io/yaacov/muza-cover-art-server:latest -f Containerfile .
  1. Basic readonly server:
podman run -p 5000:5000 -v ./images:/app/images:Z quay.io/yaacov/muza-cover-art-server:latest
  1. With upload enabled:
podman run -p 5000:5000 \
    -v ./images:/app/images:Z \
    -e ALLOW_UPLOAD=1 \
    quay.io/yaacov/muza-cover-art-server:latest
  1. With SSL (after generating certificates):
podman run -p 5000:5000 \
    -v ./images:/app/images:Z \
    -v ./certs:/app/certs:Z \
    -e USE_SSL=true \
    quay.io/yaacov/muza-cover-art-server:latest

Command Line Options

usage: muza_cover_art_server.py [-h] [--allow-upload] [--host HOST]
                                [--port PORT] [--images-dir IMAGES_DIR]
                                [--cert-file CERT_FILE] [--key-file KEY_FILE]
                                [--use-ssl]

Options:
  --allow-upload     Enable image upload endpoint
  --host HOST        Host interface (default: 0.0.0.0)
  --port PORT        Port number (default: 5000)
  --images-dir DIR   Images directory (default: images)
  --cert-file FILE   SSL certificate path (default: certs/server.crt)
  --key-file FILE    SSL key path (default: certs/server.key)
  --use-ssl          Enable SSL/TLS support

About

A lightweight server for serving and optionally uploading cover art images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published