Collobora online and Docker => How to add new fonts?

Hi,

I would like to add fonts (TTFs) to Collabora online running as docker-container on nextcloud / Ubuntu 18.04. Via Internetresearch I found out that I have to put the TTFs into the folder /usr/local/share/fonts/truetype and to add an additional parameter to the docker-command:

–volume “/usr/local/share/fonts/truetype/:/opt/collaboraoffice6.0/share/fonts/truetype/local/:ro”

But this does not work for me. I also dont have a folder /opt/collaboraofice6.0.

Now I noticed that I have to install a special “CODE”-(developer)-edition of Collabora?

Any suggestions? A step-by-step solution would be nice.

Thanks
:slightly_smiling_face:

Hello Pasteo

As I understand it there are two ways to add Collabora to Nextcloud: as a package or as a Docker image. Both ways use the Collabora Online Developer Edition (CODE) unless you want to pay for the enterprise Collabora Office.

There are CODE packages available for several Linux distributions: https://www.collaboraoffice.com/code/linux-packages/
Using this you would probably be able to add your fonts via the directory you specified; however, this is something I haven’t tried.

I don’t believe you can add fonts to the Docker container; you have to tweak the original and then create your own Docker container. The instructions are here: https://www.collaboraoffice.com/code/docker/
Again, this is not something I have tried as it probably has to be tweaked every time there is a Collabora update.

Sorry this is not the full answer we would all want!

1 Like

this folder exist in the collabora container. not on your host. i hope you know the difference.

you may run a shell in your container and have a look.

docker exec -it <name-of-collabora-conatiner> /bin/sh

if there is no shell in this container try

docker exec <name-of-collabora-conatiner> ls /opt

then you have to look what’s in the folder /opt/collaboraoffice???/share/fonts/truetype/local

if there are already ttf files and you use the --volume parameter with docker run you have to make sure that these files are also in /usr/local/share/fonts/truetype. because you map the complete folder /usr/local/share/fonts/truetype from your host to the container folder /opt/collaboraoffice???/share/fonts/truetype/local.

you could also map single files from your host to the container. but if you want to add several file this can be a long list.

btw: i guess the version 6.0 is wrong. the collabora code image has the version 4.

Hi,

First of all you are right. I used the “exec”-command so I could mount the container and -yes- the folder with the fontfiles

/opt/collaboraoffice6.0/share/fonts/truetype

is now shown. The first step into the right direction, but not yet the solution :slightly_smiling_face: But the subfolder “truetype/local” in the container mentioned in the commandlet is missing. Shall I create this subfolder? I also dont know the meaning of “local/:ro” at the end of the commandlet. Is its syntax “local/:ro” correct?

So finally if I use the commandlet

docker run -t -d -p 127.0.0.1:9980:9980 -e ‘domain=nc\.sampledomain\.com’ -e “username=user” -e “password=secret” --restart always --cap-add MKNOD collabora/code --volume “/usr/local/share/fonts/truetype/:/opt/collaboraoffice6.0/share/fonts/truetype/local/:ro”

the error is still

Error response from daemon: OCI runtime create failed: container_linux.go:346:
starting container process caused “exec: “–volume”: executable file not found in $PATH”: unknown.

It would be nice if you could post the needed commandlets step-by-step for the solution.

Thanks
:slightly_smiling_face:

You may not put the --volume at the end. collabora/code, the name of the image should be at the end.

:ro means read only. A process in the container can’t write to this folder. It’s a security feature from docker.

And the folder path should be created. Including all sub folders.

Please be so kind and post the whole command as you would type it in.

thanks

:slightly_smiling_face:

docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=nc\.sampledomain\.com' -e "username=user" -e "password=secret" --restart always --cap-add MKNOD  --volume "/usr/local/share/fonts/truetype/:/opt/collaboraoffice6.0/share/fonts/truetype/local/:ro" --name collabora collabora/code 

btw: on my ubuntu 18.04 test machine ttf fonts were install to /usr/share/fonts/truetype. so you may want to change that in the docker run command as well.

1 Like

Many Thanks, Reiner! It was the wrong syntax and your CMdlet is the solution I was looking for.

:grinning:

This command is not working :

docker run -t -d -p 127.0.0.1:9980:9980 -e ‘domain=nc\.sampledomain\.com’ --restart always --cap-add MKNOD --volume “/usr/local/share/fonts/truetype/:/root/collabora-fonts/:ro” collabora/code

Forlder /root/collabora-fonts/ not created in host, no sync

I have moved files with :
docker cp ./ubuntu thirsty_bardeen:/usr/share/fonts/truetype
docker restart collabora

This works great. Any idea how this can be implemented without having to keep track of the collabora version / folder name?

not really. maybe with links.
but you should ask this in the collabora forum. since it’s not a nextcloud problem. or?

Here is my current setup:

  • Place the fonts in a directory ./fonts

  • Add the following Dockerfile to your directory (maybe the --chown=… is not necessary)

    FROM collabora/code
    
    COPY --chown=104:106 fonts /usr/share/fonts/truetype/more/
    COPY --chown=104:106 fonts /opt/cool/systemplate/usr/share/fonts/truetype/more/
    
  • In your docker-compose.yml, change image: collabora/code to build: .. In case you do not have a docker-compose.ymlfile yet, here is an example:

     version: '3'
    services:
        lool:
          build: .
          environment:
          - domain=cloud\.example\.com|cloud\.beispiel\.ch
          restart: always
          ports:
          - "9980:9980"
          cap_add:
         - MKNOD
    
  • (Re-)start your Docker container with docker-compose up -d --build.

1 Like

Update for the docker solution (inspired by reiner_nippes proposition).

The docker image has been modified and collabora is now in /opt/collabora/ (without version number)

Therefore, the docker commando should now be:

docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=nc\.sampledomain\.com' -e "username=user" -e "password=secret" --restart always --cap-add MKNOD --volume "/usr/local/share/fonts/truetype/:/opt/collaboraoffice/share/fonts/truetype/local/:ro" --name collabora collabora/code

where:

  • /usr/local/share/fonts/truetype/ is the location on my host (ubuntu 20.04LTS). To find yours, you should do something like:
sudo updatedb
locate truetype

or with
find /usr -name truetype

  • –name collabora is optional (one will be created dynamically)
  • collabora/code is the image name and MUST be the last parameter (hint: OCI runtime failure code)
1 Like

On my system the font dir had to be owned by root and chmod 644, at least I didn’t see the fonts in collabora otherwise. I copied in all the ttf fonts from my windows 10.

For reference my full docker-compose.yml here: https://o.o5.ddns.net/Ohs2v

IMHO it is enough to have the uid/gid cool:cool (104:106). Root ownership is not necessary.

1 Like

You’re right! I’ve had wrong permissions on the parent folder, I’ve sorted that and now it works without root as well. I’ve restored snaphot where the perms were root:root, ran
sudo chown -R 104:106 collab_fonts/* && sudo chmod 644 collab_fonts/* && sudo chmod 755 collab_fonts/, rebuilt stack and the fonts show up.