A small FastAPI service for converting office documents with LibreOffice through
unoserver.
The container starts unoserver in the background, waits until it is ready, and
then serves a simple HTTP API on port 8080.
GET /healthchecks whetherunoserveris ready.POST /convertconverts an uploaded file. The optionaltoquery parameter controls the output format and defaults topdf.
Build the image:
docker build -t unoserver .Start the service:
docker run --rm -p 8080:8080 unoserverCheck health:
curl http://localhost:8080/healthConvert a document to PDF:
curl -X POST "http://localhost:8080/convert?to=pdf" \
-F "file=@example.docx" \
--output example.pdfThe repository includes basic Kubernetes manifests:
kubectl apply -f deployment.yaml
kubectl apply -f service.yamlBefore applying them, update the image in deployment.yaml to point at your
registry.
server.pydefines the FastAPI application.entrypoint.shstartsunoserverand thenuvicorn.Dockerfilebuilds the LibreOffice-based runtime image.deployment.yamlandservice.yamlprovide a basic Kubernetes deployment.