Wordpress: Configure all wp-config.php variable with Docker environment variables ?

Created on 25 Jan 2017  路  5Comments  路  Source: docker-library/wordpress

What do you think about configure wp-config.php with Docker environment variables ?

Like this:

<?php

define('WP_CONTENT_DIR', '/var/www/wp-content');

$table_prefix  = getenv('TABLE_PREFIX') ?: 'wp_';

foreach ($_ENV as $key => $value) {
  $capitalized = strtoupper($key);
  if (!defined($capitalized)) {
    define($capitalized, $value);
  }
}

if (!defined('ABSPATH'))
    define('ABSPATH', dirname(__FILE__) . '/');

require_once(ABSPATH . 'wp-settings.php');
?>

source: https://codeable.io/wordpress-developers-intro-to-docker-part-two/#configuring-wp-configphp

It is useful for instance to configure FS_METHOD=direct.

Most helpful comment

See also #8, #142, #147 (comment)

ok and what we do? This request are rejected?

I want to configure FS_METHOD=direct and I don't want mount wp-config.php. What I need to do?

All 5 comments

See also #8, #142, #147 (comment)

ok and what we do? This request are rejected?

I want to configure FS_METHOD=direct and I don't want mount wp-config.php. What I need to do?

I would be interested to know what solution you found @harobed. I am currently trying to customize wp-config and I can't get wp-config.php mounted by itself #231 #135. So I am going to just mount /var/www/html to the host.

Strangely I can mount uploads.ini by itself.

In the hope to finally have a standard/consistent/simple/flexible and secure solution from upstream WP: https://core.trac.wordpress.org/ticket/41710

Feel free to comment there about file-based passwords (although it may still appear as a niche-case to upstream ATM)

Was this page helpful?
0 / 5 - 0 ratings