Skip to main content

Runtime Configuration

in Deskpro container image
Authors list
Published: Jul 31, 2023|Last updated: Aug 15, 2024

The previous page ( Configuration with Environmental Variables) described how to configure Deskpro with env vars. In addition to those, you also have control over how some of the internal services work such as PHP. We refer to these as runtime configuration options.

There are several environmental variables you can set for common options, and then a number of special config directories where you can mount custom config files to if you need more control.

Note

The environmental variables described in this page behave the same way as the Deskpro configuration vairables (see Configuration with Environmental Variables). For example, you can use _B64 and _ESC suffixes for encoded values.

PHP INI OverridesCopy link to PHP INI Overrides to clipboard

  • PHP_INI_OVERRIDES -- arbitrary string to append to php.ini. This is mostly an alternative to mounting a custom php.ini file.

  • PHP_MEMORY_LIMIT -- PHP memory limit (default: 1G). docs.

  • PHP_OPCACHE_ENABLED -- Enable or disable opcache (default: 1). docs.

  • PHP_OPCACHE_MEMORY_CONSUMPTION -- Amount of memory (in megabytes) to allocate for opcache (default: 128). docs. If your server has enough memory, you can increase this value to 384 to improve performance.

Example env file:

# example config.env file PHP_MEMORY_LIMIT="2G" PHP_OPCACHE_MEMORY_CONSUMPTION="384" # Would be similar to: PHP_INI_OVERRIDES=" memory_limit=2G opcache.memory_consumption=384 "
copy

PHP-FPM OverridesCopy link to PHP-FPM Overrides to clipboard

  • PHP_FPM_OVERRIDES -- arbitrary string to append to php-fpm config under the 'global' group. This is mostly an alternative to mounting a custom php-fpm.conf.

  • PHP_FPM_POOL_OVERRIDES -- arbitrary string to append to all pool configs.

  • PHP_FPM_<POOL>_OVERRIDES -- arbitrary string to append to specific pool config.

    • PHP_FPM_<POOL>_MAX_CHILDREN -- Change the pm.max_children value for the pool. Default: Varies. docs.

Where <POOL> is one of the four pools:

  • DP_GQL -- Used by the GraphQL APIs by agents from the agent interface

  • DP_INTERNAL -- Used by any deskpro-to-deskpro internal API calls

  • DP_BROADCASTER -- Used by the long-lived broadcaster endpoint for browser notifications and realtime events

  • DP_DEFAULT -- Used by all other endpoints such as the v1/v2 API and the help center

Example env file:

# example config.env file PHP_FPM_OVERRIDES=" emergency_restart_threshold=10 emergency_restart_interval=10 " PHP_FPM_POOL_OVERRIDES=" pm=dynamic pm.max_children=50 pm.start_servers=1 pm.min_spare_servers=1 pm.max_spare_serve=10 "
copy

Mounted Configuration Files Copy link to Mounted Configuration Files to clipboard

You can also mount a custom config files into one of the special config directories. Your custom files will be "included" along with the default configuration for that particular service.

Note

Extra files are included in sorted order. E.g. a file named 99-my-file.conf will be loaded after 01-my-file.conf. If you want to be sure your config file is loaded last, use a 99- prefix.

  • /deskpro/config/php.d/*.ini -- Custom PHP INI files

  • /deskpro/config/php-fpm.d/*.conf -- Custom php-fpm config files. Note that if you want to set values for FPM pools, you will need to include the [pool_name] group header in your file.

  • /deskpro/ssl/ca-certificates/*.crt -- add custom CA certificates in PEM format to trust. Any files in this directory will be installed into the containers trusted certificates directory.

  • /deskpro/ssl/mysql/client.crt and /deskpro/ssl/mysql/client.key -- If these are specified, then Deskpro will enable secure MySQL connections. If the /deskpro/ssl/mysql/ca.pem file exists, that'll be installed into the trusted CA directory.

  • /deskpro/entrypoint.d/*.sh -- Custom entrypoint scripts that run during boot. These scripts get executed before services start.

  • /deskpro/config/deskpro-config.d/*.php -- Custom Deskpro configuration where you can extend/use the $CONFIG variable (be sure not to overwrite the whole variable!). Only attempt to write custom configuration if you're sure you know what you're doing.

Question

Your custom files get copied to the correct place inside the container with the most secure file permissions. This means you don't need to worry about file permissions or file ownership yourself on the mounted files. We suggest you mount files so they are owned by root and with minimal permissions (e.g. 600).

Warning

Since files are only copied and evaluated when the container first starts, any changes require the container to be restarted. This is true even if you manually restart services inside the container.

Config file templatesCopy link to Config file templates to clipboard

If you wish to use environmental variables in your own config files, then you may define you config file as a template instead. Append a *.tmpl extension to your file and it'll be evaluated with gomplate to a file with the same name minus the tmpl extension. For example, 99-my-file.ini.tmpl file will be evaluated as a template and then written as 99-my-file.ini.

Recall that there are a variety of ways to declare environmental variables (e.g. as encoded values or as mounted secrets or files). So if you want to make use of the environment, it's best to use a template which "knows" how to read the values in whatever way they were defined.

<?php # e.g. /deskpro/config/deskpro-config.d/99-my-config.php.tmpl could be a custom Deskpro configuration file to set a setting $CONFIG['settings']['some.api.key'] = {{ (getenv "SOME_ENV_VAR" "some-default-value") | php_string }};
copy

gomplate has many built-in functions and filters you can use. The Deskpro container declares three others:

  • php_string -- Outputs the value as a PHP string (e.g. takes care of quoting it, escaping quotes, etc)

  • json_to_php -- Takes a string containing JSON and outputs it as a PHP value (e.g. an object will become a PHP assoc array)

HelpfulUnhelpful
next pageLogging
previous pageConfiguration with Environmental Variables

Please log in or register to submit a comment.