---
title: Deploy Papermerge with AI on Blossom
url: "/deploy/papermerge/"
canonical_url: https://blossom88.com/deploy/papermerge/
markdown_url: https://blossom88.com/deploy/papermerge.md
summary: Find text inside a scanned PDF and reopen the original after an update.
categories:
- deployment
- documents
stack:
- Python
- FastAPI
- React
- PostgreSQL
- Redis
- Solr
---

# Deploy Papermerge with AI on Blossom

[Papermerge](https://github.com/papermerge/papermerge-core) is a document
archive with optical character recognition (OCR). Start with a scanned PDF
and search for a word that appears only on the page.

## Ask Your Agent

> **Ask your AI agent:** Deploy Papermerge on Blossom. Help me search for text inside a sample scanned PDF.
>
> Follow this guide: https://blossom88.com/deploy/papermerge/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## Have Ready

- **x86 Location** (Required): Build and deploy the supplied Papermerge image on x86.
- **Managed PostgreSQL and Redis** (Required): Link a database and a cache for accounts, document records, and OCR jobs.

## How It Runs

| Part | Role | Where |
|---|---|---|
| Papermerge and OCR | Serve the archive and extract text from scans | One Persistent Service with a shared media directory |
| Search | Index the extracted text and answer queries | Private indexing worker and Solr Persistent Service |
| PostgreSQL and Redis | Keep document records and queue work | Blossom Managed Data |

## Deploy the Archive

Keep the web process and OCR worker on one Persistent Service with the
same media directory. Run the indexing worker and Solr as private Services,
and protect the web Service with Blossom Account access.

<details class="optional-reading" markdown="1">
<summary>Notes for your agent</summary>

Build with the [Papermerge Dockerfile](/deploy/recipes/papermerge/Dockerfile).
It builds the pinned OCR worker for the Papermerge web image and starts
both through the image's Supervisor. Configure the built image as the
Environment image and let the web Service inherit it. Use port 80, at
least a medium Container, and one Volume at `/var/media/pmg`.
Link PostgreSQL and Redis as `PAPERMERGE__DATABASE__URL` and
`PAPERMERGE__REDIS__URL`. Store the administrator password and the stable
`PAPERMERGE__SECURITY__SECRET_KEY` as protected Environment variables.
Set the sample OCR language to `eng`.

Run [Solr](https://docs.papermerge.io/3.5/settings/search/) privately
on port 8983 with `solr-precreate pmg` and a Volume at `/var/solr`. Set
`PAPERMERGE__SEARCH__URL` to `solr://<private-solr-host>:8983/pmg` on
the web and indexing Services. Run the [I3 worker](https://docs.papermerge.io/3.5/setup/docker-compose/#i3-worker)
on the `i3` queue, using the same database and cache Links. Deploy Solr
first and wait for the `pmg` core before starting the web and indexing
Services.

Papermerge 3.5.3 loads its PDF.js viewer worker from `unpkg.com` in the
browser.

</details>

<details class="optional-reading" markdown="1">
<summary>Commands your agent runs</summary>

    blossom app_plan:preview --data papermerge-plan.yml
    blossom database_instance:create --data papermerge-postgres.yml
    blossom cache_instance:create --data papermerge-redis.yml
    blossom app:create --data papermerge-app.yml
    blossom environment:create --data papermerge-environment.yml
    blossom environment_link:create --data papermerge-postgres-link.yml
    blossom environment_link:create --data papermerge-redis-link.yml
    blossom service:create --data papermerge-web.yml
    blossom service:create --data papermerge-solr.yml
    blossom service:create --data papermerge-indexer.yml
    blossom environment:deploy --id environment-100 --follow
    blossom service:scale --id service-100 --desired-size 1
    blossom service:scale --id service-101 --desired-size 1

</details>

## Upload a Scan and Find a Word

Sign in to Papermerge and upload the
[sample scan](/deploy/recipes/papermerge/workshop-scan.pdf). Run English
OCR and search for **KILNWORKSHOP** once the worker finishes.

![Find a scanned PDF by text inside it.](/deploy/assets/images/papermerge/papermerge-ocr-search.webp)

> **Ask your AI agent:** Upload the sample workshop scan to Papermerge and find it by searching for KILNWORKSHOP.

> Follow this guide: https://blossom88.com/deploy/papermerge/



## Keep It Running

Keep the media and search Volumes when updating the app. After replacing
the web and indexing Containers in your test Environment, sign in again
and find the same search result. Clear **Open in other panel** to preview
the scan in the main panel, then download the original PDF.

![Reopen the original scan after replacement.](/deploy/assets/images/papermerge/papermerge-original-scan.webp)


> **Ask your AI agent:** Replace the demo app Containers and use Papermerge search to reopen the original workshop scan.

> Follow this guide: https://blossom88.com/deploy/papermerge/



## What You Get

- A document archive protected by Blossom Account access
- A sample scan you can search by words on the page
- The original PDF available after an app update

Tested on Blossom: After replacing the web, OCR, and indexing processes, a fresh sign-in found the same search result and downloaded the byte-identical original PDF.
