[GH-ISSUE #65] Discussion: New configuration system #46

Closed
opened 2026-02-25 21:31:05 +03:00 by kerem · 3 comments
Owner

Originally created by @langimike on GitHub (Aug 13, 2020).
Original GitHub issue: https://github.com/ciur/papermerge/issues/65

I have been trying to deploy papermerge on Podman containers and came to the point, where it would be necessary to customize a few settings and override config settings in the configuration files within the containers. I know this is possible via a volume mounts, but feels a bit cumbersome to me (maybe I have overlooked something, and this is possible in some more elegant way - in this case please simply close and forget this issue 😉 ).

Since I have used Django Environ in a few projects, I asked myself, if you would be interested in discussing an adoption of this configuration method in papermerge.

This way, you could use sensible defaults in a simple settings.py and in case of running on a docker/podman container have all necessary settings overridden using environment variables and in case of running under systemd with an environment file. I know, this would be quite a breaking change.

If you are interested, I am really interested in helping out and creating a pull request.

Nonetheless, it's just an idea.

Originally created by @langimike on GitHub (Aug 13, 2020). Original GitHub issue: https://github.com/ciur/papermerge/issues/65 I have been trying to deploy papermerge on Podman containers and came to the point, where it would be necessary to customize a few settings and override config settings in the configuration files within the containers. I know this is possible via a volume mounts, but feels a bit cumbersome to me (maybe I have overlooked something, and this is possible in some more elegant way - in this case please simply close and forget this issue :wink: ). Since I have used [Django Environ](https://github.com/joke2k/django-environ) in a few projects, I asked myself, if you would be interested in discussing an adoption of this configuration method in papermerge. This way, you could use sensible defaults in a simple settings.py and in case of running on a docker/podman container have all necessary settings overridden using environment variables and in case of running under systemd with an environment file. I know, this would be quite a breaking change. If you are interested, I am really interested in helping out and creating a pull request. Nonetheless, it's just an idea.
kerem 2026-02-25 21:31:05 +03:00
Author
Owner

@ciur commented on GitHub (Aug 13, 2020):

Hi @langimike

Thank you for opening this discussion.

The thing is, Papermerge used to have a configuration system very similar to django environ that you mentioned. To be honest, I really love that approach (.env file + read settings from environment variables)!

But in practice, those approaches (dotenv, django environ) have drawbacks.
One drawback (and least problematic) is that .env file limits variables syntax. I encountered this issue when I introduced metadata plugins. Metadata plugins are declared as list. IMHO python syntax is very user friendly in that regard - while .env syntax, well, it depends...

Another drawback, which I find as very is serious one - it is when it comes to deploying Papermerge/Django project in production under Apache (mod_wsgi + apache2). Passing environment variables from under apache is, to say the least - not as flexible as compared to deploying from nginx + gunicorn (or even docker containers). Apache Web server has little bit weird way of working with environment variables and it does not pass to django application variables as say gunicorn does.

So, my point is that I won't mess around with configuration system at this moment - as it is flexible enough to work in different environments (development, test, production: gunicorn, uwsgi, apache2 + mod_wsgi).

<!-- gh-comment-id:673483161 --> @ciur commented on GitHub (Aug 13, 2020): Hi @langimike Thank you for opening this discussion. The thing is, Papermerge used to have a configuration system [very similar](https://github.com/pedroburon/dotenv) to django environ that you mentioned. To be honest, I really love that approach (.env file + read settings from environment variables)! But in practice, those approaches (dotenv, django environ) have drawbacks. One drawback (and least problematic) is that .env file limits variables syntax. I encountered this issue when I introduced metadata plugins. [Metadata plugins are declared as list](https://github.com/ciur/papermerge/blob/f4a900d06c07adae57795d6d55cbc8954a54d457/papermerge.conf.py.example#L95). IMHO python syntax is very user friendly in that regard - while .env syntax, well, it depends... Another drawback, which I find as very is serious one - it is when it comes to deploying Papermerge/Django project in production under Apache (mod_wsgi + apache2). Passing environment variables from under apache is, to say the least - not as flexible as compared to deploying from nginx + gunicorn (or even docker containers). Apache Web server has little bit weird way of working with environment variables and it does not pass to django application variables as say gunicorn does. So, my point is that I won't mess around with configuration system at this moment - as it is flexible enough to work in different environments (development, test, production: gunicorn, uwsgi, apache2 + mod_wsgi).
Author
Owner

@langimike commented on GitHub (Aug 13, 2020):

I definitely understand your points.

I think, it's primarily a matter of taste, because for the first drawback django-environ supports all sorts of python datatypes and the second drawback comes from one's preferred way of deployment (apache2+mod_wsgi vs. nginx+uwsgi or nginx+daphne).

My ideas/suggestions source in me trying to configure database settings (host, user, password) within the containers. The only way I found to override them, is mounting modified app.production.py and worker.production.py to /opt/app/config/settings/production.py.

But don't mind, I got it running.

Thank you!

<!-- gh-comment-id:673607987 --> @langimike commented on GitHub (Aug 13, 2020): I definitely understand your points. I think, it's primarily a matter of taste, because for the first drawback django-environ [supports](https://django-environ.readthedocs.io/en/latest/#supported-types) all sorts of python datatypes and the second drawback comes from one's preferred way of deployment (apache2+mod_wsgi vs. nginx+uwsgi or nginx+daphne). My ideas/suggestions source in me trying to configure database settings (host, user, password) within the containers. The only way I found to override them, is mounting modified app.production.py and worker.production.py to /opt/app/config/settings/production.py. But don't mind, I got it running. Thank you!
Author
Owner

@ciur commented on GitHub (Aug 14, 2020):

Great that you have Papermerge up and running!
I will close this issue then.
Thank you!

<!-- gh-comment-id:673900506 --> @ciur commented on GitHub (Aug 14, 2020): Great that you have Papermerge up and running! I will close this issue then. Thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/papermerge#46
No description provided.