haiwen / seafile-docker

A Docker image for Seafile server
Other
536 stars 181 forks source link

[Kubernetes] Allow passing pre-generated, readonly configuration files into Seafile container #332

Open NiklasRosenstein opened 1 year ago

NiklasRosenstein commented 1 year ago

Hi 👋 I'm trying to run Seafile Pro on Kubernetes by installing it via a handcrafted Helm chart.

The issue I am encountering is that Seafile attempts to generate configuration files on startup. The environment variables that can be used to influence that config-generation step are not sufficient (such as S3 configuration), so I would like to generate the configuration files via Helm and put them into the appropriate place.

However, I can't get Seafile to not try and generate these files, and it always fails with en error like this:

Traceback (most recent call last):                                                                                                                                                                                                       File "setup-seafile-mysql.py", line 1598, in <module>                                                                                                                                                                                    main()                                                                                                                                                                                                                               File "setup-seafile-mysql.py", line 1547, in main                                                                                                                                                                                        seafile_config.generate()                                                                                                                                                                                                            File "setup-seafile-mysql.py", line 933, in generate                                                                                                                                                                                     with open(self.seafile_conf, 'w') as fp:                                                                                                                                                                                           OSError: [Errno 30] Read-only file system: '/opt/seafile/conf/seafile.conf'        

That's because the configuration files are mounted into the container by Kubernetes.

# ...
            - mountPath: /shared/seafile/conf/ccnet.conf
              name: seafile-conf
              subPath: "ccnet.conf"
              readOnly: true
            - mountPath: /shared/seafile/conf/seafile.conf
              name: seafile-conf
              subPath: "seafile.conf"
              readOnly: true
            - mountPath: /shared/seafile/conf/seafdav.conf
              name: seafile-conf
              subPath: "seafdav.conf"
              readOnly: true
            - mountPath: /shared/seafile/conf/seahub_settings.py
              name: seafile-conf
              subPath: "seahub_settings.py"
              readOnly: true

Setting them to readOnly: false doesn't help. When the container restarts, those changes would be lost but Seafile is not going to configure itself another time. Also it would require that the container "merges" with the existing configuration and prefers it.

Ideally there would be an option for the container to entirely skip config generation, yet Database initialization should still happen.

It would also need to skip any Mysql "root" checks, as I wouldn't be giving it any root credentials. I can make sure the seafile user exists when Seafile starts up.

mjohnson9 commented 1 year ago

Did you find a suitable solution to this? I'm running into the same inflexibility.

SkywalkerSpace commented 6 months ago

You can refer to this manual https://manual.seafile.com/docker/cluster/deploy_seafile_cluster_with_docker/

NiklasRosenstein commented 6 months ago

Did you find a suitable solution to this? I'm running into the same inflexibility.

I've built my own Seafile container image that allows me to mount config as a read only file and runs only one Seafile service per container.