Skip to content
Snippets Groups Projects

[#33] Move config from php fpm script to wp-config

Merged [#33] Move config from php fpm script to wp-config
Merged Georgios Tsoulos requested to merge feature/GL-33 into mvp

Description

Move and add dynamic configuration improvements to our WordPress container setup:

  • Dynamic Database & Site Settings:
    • Database credentials and table prefix are loaded from environment variables from wp-config.php.
    • Site URL constants (e.g. WP_HOME, WP_SITEURL) are defined based on the APPLICATION_NAME environment variable and loaded from wp-config.php.
    • Filters override site options like blogname and admin_email to reflect environment values without unnecessary database writes.
  • Dynamic OpenID Connect Settings:
    • A must-use plugin (openid-settings.php) has been added to automatically update the openid_connect_generic_settings option during the init hook.
    • The plugin merges existing settings with new values derived from environment variables, ensuring that the OpenID Connect plugin always uses current configuration data without manual intervention.
  • Dynamic Authentication Keys & Salts:
    • Instead of hardcoding security keys, the configuration now fetches random salted keys from the WordPress.org secret-key API and defines them dynamically.

Testing

  1. Run make build & make up.

  2. Checked if openid_connect_generic_settings existed:

    Screenshot 2025-03-18 at 11.36.22.png

  3. Blog Options are correctly populated:

    Screenshot 2025-03-18 at 11.37.26.png

  4. Security keys are salted and correctly populated

    Screenshot 2025-03-18 at 11.39.17.png

  5. Site correctly loads !

Edited by Georgios Tsoulos

Merge request reports

Merge request pipeline #11068283 passed

Merge request pipeline passed for 89149960

Approved by

Merged by Carina AntunesCarina Antunes 1 month ago (Apr 9, 2025 3:43pm UTC)

Loading

Pipeline #11696832 passed

Pipeline passed for 360ae972 on mvp

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Please include this as the last bit before ... wp-setting.php

    // Local configuration file should be in project root.
      if (file_exists(dirname(__FILE__, 2) . '/wp-config-local.php')) {
        include(dirname(__FILE__, 2) . '/wp-config-local.php');
      }
    

    We can then on the operator codebase mount a configmap as file under the wp-config-local.php in case we need custom configs in a project

  • Georgios Tsoulos changed title from [#33 (closed)] [WIP] Move config from php fpm script to wp-config to [#33 (closed)] Move config from php fpm script to wp-config

    changed title from [#33 (closed)] [WIP] Move config from php fpm script to wp-config to [#33 (closed)] Move config from php fpm script to wp-config

  • added 1 commit

    • 777a2f73 - Use salt and move the openid settings

    Compare with previous version

  • Georgios Tsoulos changed the description

    changed the description

  • added 8 commits

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • I pushed a review, because changes were needed in order to validate functionality locally. There's a couple of options/issues to discuss, let's chat offline tomorrow!

  • Hi again, to complement on the logic loading the optional file wp-config-local.php, I propose:

    • We add an optional field to the CRD, something like "extra-config: string" which will contain the name of the configmap.
    • On the operator, if the field exists we try to mount the configmap. This way the resource is manual, and we don't ever reconcile it.

    Wdyt?

    asking @rpareek to review the suggestion as well

  • Carina Antunes mentioned in merge request !62 (merged)

    mentioned in merge request !62 (merged)

  • Carina Antunes resolved all threads

    resolved all threads

  • Carina Antunes approved this merge request

    approved this merge request

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading