|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * The base configuration for WordPress |
| 4 | + * |
| 5 | + * The wp-config.php creation script uses this file during the installation. |
| 6 | + * You don't have to use the website, you can copy this file to "wp-config.php" |
| 7 | + * and fill in the values. |
| 8 | + * |
| 9 | + * This file contains the following configurations: |
| 10 | + * |
| 11 | + * * Database settings |
| 12 | + * * Secret keys |
| 13 | + * * Database table prefix |
| 14 | + * * ABSPATH |
| 15 | + * |
| 16 | + * This has been slightly modified (to read environment variables) for use in Docker. |
| 17 | + * |
| 18 | + *@link https://wordpress.org/documentation/article/editing-wp-config-php/ |
| 19 | + * |
| 20 | + * |
| 21 | + * @package WordPress |
| 22 | + */ |
| 23 | + |
| 24 | +// IMPORTANT: this file needs to stay in-sync with https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php |
| 25 | +// (it gets parsed by the upstream wizard in https://github.com/WordPress/WordPress/blob/f27cb65e1ef25d11b535695a660e7282b98eb742/wp-admin/setup-config.php#L356-L392) |
| 26 | + |
| 27 | +// a helper function to lookup "env_FILE", "env", then fallback |
| 28 | +if (!function_exists('getenv_docker')) { |
| 29 | + // https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x) |
| 30 | + function getenv_docker($env, $default) { |
| 31 | + if ($fileEnv = getenv($env . '_FILE')) { |
| 32 | + return rtrim(file_get_contents($fileEnv), "\r\n"); |
| 33 | + } |
| 34 | + else if (($val = getenv($env)) !== false) { |
| 35 | + return $val; |
| 36 | + } |
| 37 | + else { |
| 38 | + return $default; |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +// ** Database settings - You can get this info from your web host ** // |
| 44 | +/** The name of the database for WordPress */ |
| 45 | +define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') ); |
| 46 | + |
| 47 | +/** Database username */ |
| 48 | +define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') ); |
| 49 | + |
| 50 | +/** Database password */ |
| 51 | +define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') ); |
| 52 | + |
| 53 | +/** |
| 54 | + * Docker image fallback values above are sourced from the official WordPress installation wizard: |
| 55 | + * https://github.com/WordPress/WordPress/blob/1356f6537220ffdc32b9dad2a6cdbe2d010b7a88/wp-admin/setup-config.php#L224-L238 |
| 56 | + * (However, using "example username" and "example password" in your database is strongly discouraged. Please use strong, random credentials!) |
| 57 | + */ |
| 58 | + |
| 59 | +/** Database hostname */ |
| 60 | +define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') ); |
| 61 | + |
| 62 | +/** Database charset to use in creating database tables. */ |
| 63 | +define( 'DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8') ); |
| 64 | + |
| 65 | +/** The database collate type. Don't change this if in doubt. */ |
| 66 | +define( 'DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', '') ); |
| 67 | + |
| 68 | +/**#@+ |
| 69 | + * Authentication unique keys and salts. |
| 70 | + * |
| 71 | + * Change these to different unique phrases! You can generate these using |
| 72 | + * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}. |
| 73 | + * |
| 74 | + * You can change these at any point in time to invalidate all existing cookies. |
| 75 | + * This will force all users to have to log in again. |
| 76 | + * |
| 77 | + * @since 2.6.0 |
| 78 | + */ |
| 79 | +define( 'AUTH_KEY', getenv_docker('WORDPRESS_AUTH_KEY', 'put your unique phrase here') ); |
| 80 | +define( 'SECURE_AUTH_KEY', getenv_docker('WORDPRESS_SECURE_AUTH_KEY', 'put your unique phrase here') ); |
| 81 | +define( 'LOGGED_IN_KEY', getenv_docker('WORDPRESS_LOGGED_IN_KEY', 'put your unique phrase here') ); |
| 82 | +define( 'NONCE_KEY', getenv_docker('WORDPRESS_NONCE_KEY', 'put your unique phrase here') ); |
| 83 | +define( 'AUTH_SALT', getenv_docker('WORDPRESS_AUTH_SALT', 'put your unique phrase here') ); |
| 84 | +define( 'SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', 'put your unique phrase here') ); |
| 85 | +define( 'LOGGED_IN_SALT', getenv_docker('WORDPRESS_LOGGED_IN_SALT', 'put your unique phrase here') ); |
| 86 | +define( 'NONCE_SALT', getenv_docker('WORDPRESS_NONCE_SALT', 'put your unique phrase here') ); |
| 87 | +// (See also https://wordpress.stackexchange.com/a/152905/199287) |
| 88 | + |
| 89 | +/**#@-*/ |
| 90 | + |
| 91 | +/** |
| 92 | + * WordPress database table prefix. |
| 93 | + * |
| 94 | + * You can have multiple installations in one database if you give each |
| 95 | + * a unique prefix. Only numbers, letters, and underscores please! |
| 96 | + */ |
| 97 | +$table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_'); |
| 98 | + |
| 99 | +/** |
| 100 | + * For developers: WordPress debugging mode. |
| 101 | + * |
| 102 | + * Change this to true to enable the display of notices during development. |
| 103 | + * It is strongly recommended that plugin and theme developers use WP_DEBUG |
| 104 | + * in their development environments. |
| 105 | + * |
| 106 | + * For information on other constants that can be used for debugging, |
| 107 | + * visit the documentation. |
| 108 | + * |
| 109 | + * @link https://wordpress.org/documentation/article/debugging-in-wordpress/ |
| 110 | + */ |
| 111 | +define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') ); |
| 112 | + |
| 113 | +/* Add any custom values between this line and the "stop editing" line. */ |
| 114 | + |
| 115 | +// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact |
| 116 | +// see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy |
| 117 | +if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) { |
| 118 | + $_SERVER['HTTPS'] = 'on'; |
| 119 | +} |
| 120 | +// (we include this by default because reverse proxying is extremely common in container environments) |
| 121 | + |
| 122 | +if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) { |
| 123 | + eval($configExtra); |
| 124 | +} |
| 125 | + |
| 126 | +/* That's all, stop editing! Happy publishing. */ |
| 127 | + |
| 128 | +/** Absolute path to the WordPress directory. */ |
| 129 | +if ( ! defined( 'ABSPATH' ) ) { |
| 130 | + define( 'ABSPATH', __DIR__ . '/' ); |
| 131 | +} |
| 132 | + |
| 133 | +/** Sets up WordPress vars and included files. */ |
| 134 | +require_once ABSPATH . 'wp-settings.php'; |
0 commit comments