Best practices for managing Script executor images for processmaker

65 Views Asked by At

I have a process maker initialisation running in a Docker swarm cluster. It works well but I have an issue. When the script executors are created process maker goes and makes a docker image with a specific version tag. I think this is particular for your initialisation. It's a strange implementation. On the plus side it means you can add your own common libraries, on the minus side my cluster will clean out unused images from time to time which makes the scripts generate errors when they execute.

I have my own docker image repository which I use for my images for my projects.This is a standard practice that is used in AWS and google and other docker clouds.

What you do is name the images following this convention:

dockerregistry.mysite.com/image_name:1.2.3

Then each node on the cluster has login credentials for the registry. Docker will just pull (and push) the images to the registry. Works well for me in my cluster, as well on AWS container service.

Processmaker will generate images for me following the following convention:

processmaker4/executor-processmaker-python-4:v1.1.12  

Does processmaker have a setting that could change it from using 'processmaker4' to something else? If it did then I would be able to simply generate the images as normal and push them.

If not, what is the best practice in this area?

1

There are 1 best solutions below

0
On

Based on looking into the codebase I have come up with a very dirty hack which will fix the issue for me for now. Long term it will be nice if processmaker has a config var for this.

I am sharing it in case it's useful to others. (Hopefully in the future an expert will put a better answer here)

There are two places in the source code that need to be changed. I added the following to my docker file. (This will break when processmaker code changes)

# Hack to make it use images from my own repo for script executors
RUN sed -i "s/return \x22processmaker4\/executor-{\x24instance}-{\x24lang}-{\x24id}:{\x24tag}\x22;/return \x22dockerregistry.site.com\/executor-{\x24instance}-{\x24lang}-{\x24id}:{\x24tag}\x22;/g" ./ProcessMaker/Models/ScriptExecutor.php

RUN sed -i "s/\x24filter = \x22processmaker4\/executor-{\x24instance}-\x22;/\x24filter = \x22dockerregistry.site.com\/executor-{\x24instance}-\x22;/g" ./ProcessMaker/Models/ScriptExecutor.php

(Change dockerregistry.site.com to your docker registry url)

Then I deployed processmaker as normal.

Once that was done I generated the script executor docker image. (I used the front end but you can also do it with a backend command.)

Log into the registry:

docker login dockerregistry.site.com --username user --password pass

and push the image. (Yours will be different, this is pushing my custom executor)

docker push dockerregistry.site.com/executor-processmaker-python-4:v1.1.12

Now as long as your cluster is set up properly the right image will be pulled if it is cleaned up. I bumped up the timeout for the script. (I try and make the executor images as small as possible and have them on a fast network otherwise the script may timeout.)

Actually as processmaker has retries built in bumping up the timeout may not have been needed.

An alternative approach would be to stop the images from being cleaned up on your cluster but not all clusters have this feature.

I am hoping a Processmaker dev or PHP expert will see this and submit a PR to processmaker that turns processmaker4 into a config variable and replaces this answer with a better one.