Python Scripts with docker

Hello everyone!

I’m trying to run CODE image with Python scripts locally. It was just docker pull collabora/code, then docker run … -e extra_params="--o:security.enable_macros_execution=true --o:security.macro_security_level=0" didn’t help. After this I see the button to run macros in the ‘File’ tab, but clicking on it show list of some, I assume, default macros, but they can not be run. I tried to bind-mount some python scripts with docker run -v ~/macros/python:/opt/collaboraoffice/Scripts/python(~/macros/python is not empty), but nothing changed in the list.

Am I missing something? Maybe the only way to add macros is building from source with adding COPY ~/macros/python /opt/collaboraoffice/Scripts/python to Dockerfile, and do i have to install collaboraofficebasis-python-script-provider and collaboraofficebasis-pyuno on local machine in that case?

Thanks in advance!

hii @coolio

The most reliable way to include your Python macros is to build a custom Docker image.

Why:

  • Guaranteed Inclusion: Simply volume mounting (-v) might not always trigger the Collabora Online server to pick up new scripts immediately.
  • Persistence: Your macros will be part of the image, available every time you run the container.

How:

  1. Create a Dockerfile:

    FROM collabora/code:latest
    COPY ./macros/python /opt/collaboraoffice/Scripts/python
    

    (Place your .py scripts in a local ./macros/python folder next to the Dockerfile.)

  2. Build the image:

    docker build -t my-code-with-macros .
    
  3. Run your custom image:

    docker run -t -d -p 9980:9980 --name collabora-online my-code-with-macros
    

Ensure the macro execution parameters (--o:security.enable_macros_execution=true --o:security.macro_security_level=0) are correctly passed to the docker run command if needed.