Skip to content

How to handle dynamic or frequently changing configuration files

When building an application, developers often need to specify configurations like the database URL, API keys, and other settings. Typically, these configurations are passed to the application via environment variables. However, some applications require configuration data to be read from a file (such as an INI or YAML file).

Configuration files are useful when an application requires a more structured configuration data or when the data needs to be specified in a particular format. For example, some web servers may require an INI file to specify how to handle requests, while others may require a YAML file to define the routing rules. Apache, the popular web server, for example reads its configuration from a file called httpd.conf. Many Python applications use INI or YAML files for configuration, such as Flask and Django.

Dealing with configuration files

However, configuration files can pose a challenge in environments where configuration data changes often or when they contain environment-specific data. For example, different environments (e.g., development, staging, production) may have different routing rules, which need to be specified in the configuration file. This means that the configuration file cannot be committed to the code repository or embedded into the container at the build stage.

To address this challenge, Patr offers a feature called Config Mounts. Config Mounts allow users to mount dynamic configuration files into the Deployment from the Patr UI. This means that users can upload and edit configuration files directly from the UI, and these changes will be immediately available to the application.

Config mounts are a great way to manage configuration files in a dynamic environment where configuration data changes frequently. For example, if you need to update the configuration file for your Express web framework, you can do it directly from the UI without having to rebuild and redeploy the application.

Note: It is important to note that while Config Mounts provide a convenient way to manage configuration files, they are stored in Patr's database in plain text, and may not be the best choice for storing sensitive information due to the risk of exposure. If your configuration file contains sensitive information, we recommend using Patr's Secrets feature to store them securely.

Setting up a Config Mount for your Deployment

In order to setup a Config Mount for your Deployment, navigate to your Deployment Dashboard, and click on the Manage Deployment button. In the Manage Deployment screen, select the Deployment Details tab, and scroll down to the Config Mounts section. Here, you can create new Config Mounts as well as edit existing ones.

Screenshot of create deployment screen 2

We provide you with a VSCode-like editor to make it simpler for you to be able to change your configuration files.

In summary, Patr's "Config Mounts" feature allows users to mount dynamic configuration files into their application container from the Patr UI. This allows developers to manage application configurations that are dynamic and environment-specific, and update them without having to rebuild and redeploy the application.

Further Reading

Persisting Data Across Restarts
Zero Downtime Deployments