Managing env. variables in a simple way and deploying them on a VPS

The way we do it is to have the code in our application only depend on settings in the configuration files.
These settings are then filled in by defaults on the development environment, but are fetched from environment variables in production.

Because all environment variable names are now mentioned in the production configuration, it is easier to see what needs to be configured.

In production, there are tools to make setting up the environment variables less error-prone. In our deployment process we specify a file that contains the environment variables in the application’s systemd service configuration (see that topic for more information and steps on how to do this). This does not require any extra tools, because systemd is already the thing that manages services by default on most Unix-machines.

1 Like