linuxserver / docker-unifi-network-application

GNU General Public License v3.0
553 stars 41 forks source link

[FEAT] Support mongo+srv protocol #41

Closed MaartenUreel closed 6 months ago

MaartenUreel commented 7 months ago

Is this a new feature request?

Wanted change

The current system.properties file contains thi

db.mongo.uri=mongodb://~MONGO_USER~:~MONGO_PASS~@~MONGO_HOST~:~MONGO_PORT~/~MONGO_DBNAME~?tls=~MONGO_TLS~~MONGO_AUTHSOURCE~
statdb.mongo.uri=mongodb://~MONGO_USER~:~MONGO_PASS~@~MONGO_HOST~:~MONGO_PORT~/~MONGO_DBNAME~_stat?tls=~MONGO_TLS~~MONGO_AUTHSOURCE~

If we could replace mongodb:// with mongodb+srv:// we could run it on managed databases such as DigitalOcean.

I tested it on a normal Droplet and it works, so I am pretty confident this will work too.

Reason for change

Compatibilty with managed MongoDB services

Proposed code change

Add new variable MONGO_PROTOCOL which defaults to mongodb but could thus be set to mongodb+srv

github-actions[bot] commented 7 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

thespad commented 7 months ago

I'm kind of loath to add even more envs unless there's a significant need, we're already up to 7 for DB configuration. You can just supply your own system.properties with the necessary URI scheme and the container will use it.

MaartenUreel commented 7 months ago

I ended up going for a Droplet on DigitalOcean anyway since they do not support multiple ports to be exposed on their App Service.

Also I could not mount persistent volumes like with classical docker setup, hence the need for extra variables.

In the end, it might have made more sense perhaps to just have one variable with the entire connectionstring instead of all the parameters related to MongoDB :)

thespad commented 7 months ago

You'll get all kinds of weird issues if you don't have persistent storage for the Unifi container, but that aside we've typically found that asking users to provide a full connection URI for databases is a support nightmare so we try and avoid it.