Skip to content

Docker Go-Fitz/Libmupdf.So dependency issues #474

Description

@SlothMecha

I'm unfortunately highly inexperienced with anything related to programming-- even describing me as a hobbyist would be generous-- and thought having a local instance of LocalAGI would be an interesting one-off to learn more about what my PC can do with LLMs with (relatively) minimal security risks. I was able to compile LocalAGI in Docker with some assistance, however kept running into some last-step issues running "docker compose up" to finalize and run the container centering around libmupdf.

Owing to my general inexperience (again, I apologize), here's what Docker spat back out at me with some coaxing:

"SYSTEM SPECIFICATIONS

OS: Windows 10 with Docker Desktop (WSL 2 - Ubuntu backend)
Go Version Required: 1.26.0
Docker Version: Latest (from docker compose output)
Node/Bun: Bun 1.3.14
Build Tool: Docker Compose v5.1.3

ISSUE SUMMARY

The LocalAGI Docker container fails to start with the following error:

panic: cannot load library: libmupdf.so: cannot open shared object file: No such file or directory

goroutine 1 [running]:
github.com/gen2brain/go-fitz.loadLibrary()
/go/pkg/mod/github.com/gen2brain/go-fitz@v1.24.15/purego_linux.go:18 +0x7a
github.com/gen2brain/go-fitz.init.0()
/go/pkg/mod/github.com/gen2brain/go-fitz@v1.24.15/fitz_nocgo.go:573 +0x17

Exit Code: 2

ROOT CAUSE

The go-fitz library (v1.24.15) in purego mode attempts to load libmupdf.so dynamically at runtime.
The library is not available in standard Linux Logical package repositories, making it impossible
to install via apt-get in Docker containers.

DEPENDENCY CHAIN

LocalAGI depends on:

  • github.com/gen2brain/go-fitz v1.24.15 (for PDF processing)
    • Requires: libmupdf.so (MuPDF library - shared object file)
    • Uses: purego mode (pure Go without CGO)
    • Loads library dynamically at initialization (fitz_nocgo.go:573)

DOCKER BUILD APPROACHES ATTEMPTED

  1. Alpine Linux

    • Status: FAILED
    • Reason: mupdf-libs package not available or doesn't provide libmupdf.so
  2. Ubuntu 24.04

    • Status: FAILED
    • Reason: libmupdf/libmupdf2 packages not found in repositories
  3. Debian Bookworm

    • Status: FAILED
    • Reason: libmupdf packages not found in repositories
  4. Ubuntu 22.04

    • Status: FAILED
    • Reason: libmupdf2 package not found in repositories
  5. Building MuPDF from Source (Ubuntu 22.04 base)

    • Status: FAILED
    • Reason: Git clone of ArtifexSoftware/mupdf succeeded but make build failed
    • Error: "make build=release shared=yes" did not complete successfully (exit code: 2)
  6. CGO_ENABLED=1 with Static Linking

    • Status: FAILED
    • Reason: Go build failed during compilation
  7. CGO_ENABLED=0 (Pure Go)

    • Status: SUCCEEDED (Binary built: 57MB)
    • Issue: Binary runs but fails at initialization when go-fitz tries to load libmupdf.so

FINAL WORKING DOCKERFILE

The Go binary successfully compiles when using:

  • Base: golang:1.26-bookworm
  • CGO_ENABLED=0
  • Binary output: /tmp/localagi (57MB)
  • Runtime base: debian:bookworm-slim or ubuntu:22.04

However, runtime fails because libmupdf.so cannot be found or installed."

I'm unsure where to go from here. Would it be possible to submit a prebuilt image to Docker hub or something?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions