Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions for handling config.php with Dockerized EspoCRM #9

Closed
bliles opened this issue Oct 12, 2021 · 6 comments
Closed

Suggestions for handling config.php with Dockerized EspoCRM #9

bliles opened this issue Oct 12, 2021 · 6 comments

Comments

@bliles
Copy link

bliles commented Oct 12, 2021

Could you provide feedback on best practices for managing data/config.php with a docker build of EspoCRM?

This file contains configuration that needs to be persisted across a cluster of web nodes, for example, tabList and smtp settings, therefore I would like to track the file in our git repo and include it in our build of the app, but doing this with the stock docker image causes the Espo installation process to fail because the installer thinks that the app has already been installed if this file is present. Also config.php contains values like siteUrl that should not be baked into the image since it needs to be per environment.

@bliles
Copy link
Author

bliles commented Oct 14, 2021

This is what I've come up with so far as part of the container startup to build the proper config files for Espo.

<?php

$config = include("/path/to/templates/config.php");
$config['siteUrl'] = getenv('ESPOCRM_SITE_URL');
file_put_contents("/var/www/html/data/config.php", "<?php\nreturn " . var_export($config, true) . ";\n");

$configInternal = include("/path/to/templates/config-internal.php");
$configInternal['database']['host'] = getenv('ESPOCRM_DATABASE_HOST');
$configInternal['database']['dbname'] = getenv('ESPOCRM_DATABASE_NAME');
$configInternal['database']['user'] = getenv('ESPOCRM_DATABASE_USER');
$configInternal['database']['password'] = getenv('ESPOCRM_DATABASE_PASSWORD');
$configInternal['passwordSalt'] = getenv('ESPOCRM_PASSWORD_SALT');
$configInternal['cryptKey'] = getenv('ESPOCRM_CRYPT_KEY');
$configInternal['hashSecretKey'] = getenv('ESPOCRM_HASH_SECRET_KEY');

file_put_contents("/var/www/html/data/config-internal.php", "<?php\nreturn " . var_export($configInternal, true) . ";\n");

@tmachyshyn
Copy link
Collaborator

Hello,

You can define these parameters while creating the container. Please see https://hub.docker.com/r/espocrm/espocrm under Installation Environments section.
Also, you can change any config option (string, integer, boolean) by using Config Environments. See https://hub.docker.com/r/espocrm/espocrm.

@bliles
Copy link
Author

bliles commented Oct 15, 2021

I found that using the method you mention resulted in Espo doing an install during container start. The install process generated new cryptKey, passwordSalt and hashSecretKey values. These values need to remain consistent between deploys to the same environment/multiple nodes in the same cluster.

@tmachyshyn
Copy link
Collaborator

In this case, you have to create a data/config.php file before starting the installation process in the way you described above.

@mich3000
Copy link

mich3000 commented Nov 15, 2021

In this case, you have to create a data/config.php file before starting the installation process in the way you described above.

Hello,

You can define these parameters while creating the container. Please see https://hub.docker.com/r/espocrm/espocrm under Installation Environments section. Also, you can change any config option (string, integer, boolean) by using Config Environments. See https://hub.docker.com/r/espocrm/espocrm.

Version 7 also uses config-internal.php. How can i set parameters in docker-compose for that file.
Thanks

@tmachyshyn
Copy link
Collaborator

This is automatically defined on the EspoCRM side. All items in the systemItems will be added to the config-internal.php.
If you need some extra parameters to be added to the config-internal.php, you have to add to config.php the code:

'systemItems' => [
    '__APPEND__',
    'YOUR_PARAMETER'
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants