Dain Bentley
· 6 min read

Getting Organized with Mayan EDMS

Mayan is a web-based free document management system for managing documents within an organization. In this article I'll show you how to deploy Mayan EDMS in Docker what what features it can provide.

Getting Organized with Mayan EDMS

Paperwork is time consuming to organize and track.  There is a study that shows it takes the average worker about 10 minutes to find a document.  Paperwork get's lost, misplaced and takes time to file and retrieve.  For those of us with small home offices or small businesses - finding a solution that is cost-effective and easy to use can be a challenge.  There are several open source projects out there such as paperless and OpenKM, but in my opinion I think Mayan EDMS fits all the requirements needed by a small organization to include OCR capabilities, searching and filing options and minimal configuration and implementation issues.  There is the awesome addition of the fact it is free - as in beer - as well.  So really the only thing you lose out on is time.

Setting up Mayan is rather simple.  There is a Docker image and you simply deploy a PostgresSQL Docker image and a Mayan EDMS image.  In my case I created a Docker service for each and connected them using an overlay network.

First, I created a couple of docker volumes for persistent data.  I use NFS as storage but you can use local storage, S3 or anything else you want.  

# docker volume create --driver local --opt type=nfs --opt o=addr=xxx.xxx.xxx.xxx,rw --opt device=:/mnt/array1/docker/postgresql postgresql

# docker volume create --driver local --opt type=nfs --opt o=addr=xxx.xxx.xxx.xxx,hard,nolock,rw --opt device=:/mnt/array1/docker/mayanedms mayanedms

After that, I fire up the PostgresSQL container

docker service create \
--name mayan-edms-postgres \
-p 5432:5432 \
-e POSTGRES_USER=mayan \
-e POSTGRES_DB=mayan \
-e POSTGRES_PASSWORD=VerySecretPassword \
--mount src=postgresql,dst=/var/lib/postgresql/data \
--network prodnet \
--replicas 1 \
--constraint node.role==worker \
-d postgres:9.5

Once the PostgresSQL container is up I deploy my Mayan container.  Now - I use NFS as a storage back-end for persistent volumes.  In this particular example I will also mount another NFS volume to the container.  Mayan can consume documents by watching a particular directory and importing documents sent to this directory.  I will show how this is configured.

docker service create \
--name mayan-edms \
-p 8006:8000 \
-e MAYAN_DATABASE_ENGINE=django.db.backends.postgresql \
-e MAYAN_DATABASE_HOST=xxx.xxx.xxx.xxx \
-e MAYAN_DATABASE_NAME=mayan \
-e MAYAN_DATABASE_PASSWORD=VerySecretPassword \
-e MAYAN_DATABASE_USER=mayan \
-e MAYAN_DATABASE_CONN_MAX_AGE=60 \
--mount src=mayanedms,dst=/var/lib/mayan \
--mount 'type=volume,src=documents,volume-driver=local,dst=/mnt/documents,volume-opt=type=nfs,volume-opt=device=xxx.xxx.xxx.xxx:/mnt/array1/Documents,"volume-opt=o=addr=xxx.xxx.xxx.xxx,hard,nolock,rw"' \
--network prodnet \
--replicas 1 \
--constraint node.role==worker \
-d mayanedms/mayanedms:latest

The second mount option defined here:

--mount 'type=volume,src=documents,volume-driver=local,dst=/mnt/documents,volume-opt=type=nfs,volume-opt=device=xxx.xxx.xxx.xxx:/mnt/array1/Documents,"volume-opt=o=addr=xxx.xxx.xxx.xxx,hard,nolock,rw"' \

Shows I'm mounting an NFS volume to the container directly.  Part of my workflow is to dump documents into this directory from another application.  Mayan EDMS scans this document and uploads them so I can sort them later.  

Now I access the Mayan page, you will be given a password to use to log in.  Go to the users portion of the application to change the password immediately

Go to the users area and change the password and email:

Log out and then log back in to make sure everything worked.  At this point, I want to set up a consumption method:

Go to System, Setup:

Then go to Sources

In here you can define sources, I like to do watch folders - but you can do emails accounts and other options.  

On the action button on the far right, add a new location.  I use a watch folder:

Here you will fill out the relevant information.  If you look back further in the article you'll see the NFS volume I mounted to the container service.  This volume will be the volume I configure for Mayan EDMS to consume documents

You can create a label and change the interval time as you see fit.  I want to test to ensure it works so I'll upload a document to the directory and test it.  In my workflow, the documents are uploaded via NextCloud.  Mayan will import than from there.  Now there's two different methods, staging and uploads.  Staging will leave the documents in place and upload an OCR image until the documents are manually moved.  The feature I'm using actually takes the documents and imports them into Mayan.  You can read more about the differences here.

As you can see, I've uploaded the document via NextCloud to the "uploads" folder in NextCloud.  I'm impatient so let's go back to the Sources part of Mayan and have it check the folder now:

If I look back in NextCloud, the folder will be empty - but don't panic!  If it's empty Mayan is doing what it should and pulling the documents in.  Now lets see if it was a success.

Okay, empty upload folder, does Mayan have it?  You can see by checking the "Recent Documents" or "All Documents".  Mayan EDMS also as an OCR capability so you can both preview and search for content in the document.

Let's preview the document:

On the side, you'll see a number of links, you can explore more such as viewing the document properties or seeing if there is duplicates:

Well, now that documents have been uploaded, we should file them, this is done by the concept of cabinets.  So let's create a cabinet and file the document.  Cabinets are created via the top menu:

The steps are pretty self explanatory.  Chose the "Create Cabinet" option and then name it:

Now let's file the file.  Go back to the file - or if you so choose - you can do a bulk filing but going to the documents page and clicking the check box and selecting "Add to Cabinet":

As  you can see you can select multiple documents. If you upload a bunch and need to add them to a cabinet this is certainly the easiest way.  You can add documents to multiple cabinets as well.  

When you go back to preview the document, you'll note there is a note showing which cabinet or cabinets the document resides:

If all the tests are successful and this is an installation you want to keep, the next step would be to create users and add them to roles and give them access.  This can be done through the setup menu as well.  In another article I'll break down the different user roles and how to set up advanced workflows and explore the other features you can find in Mayan EDMS  

Mayan EDMS is a good edition to any small or home office where paper overflow is an issue.  It's easy to set up, relatively cheap in terms of cost and overhead and it is very configurable.  Granted there are some missing features that might be needed for large organizations, law firms or the government agencies it should fit the needs for most places.