Skip to content

Commit 69ea668

Browse files
committed
1. Change template files to use environment variables 2. Add respective environment variables in docker-compose-admin.yml Signed-off-by: Mriyam Tamuli <mbtamuli@gmail.com>
1 parent 5796074 commit 69ea668

4 files changed

Lines changed: 42 additions & 71 deletions

File tree

src/Admin_Tools_Command.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public function enable( $args, $assoc_args ) {
128128
'ee_root_dir' => EE_ROOT_DIR,
129129
'db_path' => DB,
130130
'ee_admin_path' => '/var/www/htdocs/ee-admin',
131+
'redis_host' => $this->site_data->cache_host,
132+
'db_host' => $this->site_data->db_host,
131133
];
132134
$docker_compose_admin = EE\Utils\mustache_render( ADMIN_TEMPLATE_ROOT . '/docker-compose-admin.mustache', $docker_compose_data );
133135
$this->fs->dumpFile( $this->site_data->site_fs_path . '/docker-compose-admin.yml', $docker_compose_admin );

templates/docker-compose-admin.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ version: '3.5'
33
services:
44

55
php:
6+
environment:
7+
- REDIS_HOST={{redis_host}}
8+
- DB_HOST={{db_host}}
69
volumes:
710
- "{{ee_root_dir}}/admin-tools:{{ee_admin_path}}:ro"
811
- "{{db_path}}:{{db_path}}:ro"

templates/pma.config.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $i++;
3030
/* Authentication type */
3131
$cfg['Servers'][$i]['auth_type'] = 'cookie';
3232
/* Server parameters */
33-
$cfg['Servers'][$i]['host'] = 'global-db';
33+
$cfg['Servers'][$i]['host'] = getenv('DB_HOST');
3434
$cfg['Servers'][$i]['compress'] = false;
3535
$cfg['Servers'][$i]['AllowNoPassword'] = false;
3636

templates/pra.config.mustache

Lines changed: 36 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,50 @@
11
<?php
22

3-
$config = array(
4-
'servers' => array(
5-
array(
6-
'name' => getenv('VIRTUAL_HOST'), // Optional name.
7-
'host' => 'global-redis',
8-
'port' => 6379,
9-
'filter' => '*',
10-
'scheme' => 'tcp', // Optional. Connection scheme. 'tcp' - for TCP connection, 'unix' - for connection by unix domain socket
11-
'path' => '' // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock'
3+
include 'config.sample.inc.php';
124

13-
// Optional Redis authentication.
14-
//'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server.
15-
),
5+
$admin_user = getenv('ADMIN_USER');
6+
$admin_pass = getenv('ADMIN_PASS');
167

17-
/*array(
18-
'host' => 'localhost',
19-
'port' => 6380
20-
),*/
21-
22-
/*array(
23-
'name' => 'local db 2',
24-
'host' => 'localhost',
25-
'port' => 6379,
26-
'db' => 1, // Optional database number, see http://redis.io/commands/select
27-
'databases' => 1, // Optional number of databases (prevents use of CONFIG command).
28-
'filter' => 'something:*', // Show only parts of database for speed or security reasons.
29-
'seperator' => '/', // Use a different seperator on this database (default uses config default).
30-
'flush' => false, // Set to true to enable the flushdb button for this instance.
31-
'charset' => 'cp1251', // Keys and values are stored in redis using this encoding (default utf-8).
32-
'keys' => false, // Use the old KEYS command instead of SCAN to fetch all keys for this server (default uses config default).
33-
'scansize' => 1000 // How many entries to fetch using each SCAN command for this server (default uses config default).
34-
),*/
35-
),
36-
37-
38-
'seperator' => ':',
39-
40-
41-
// Uncomment to show less information and make phpRedisAdmin fire less commands to the Redis server. Recommended for a really busy Redis server.
42-
//'faster' => true,
43-
44-
45-
// Uncomment to enable HTTP authentication
46-
/*'login' => array(
47-
// Username => Password
48-
// Multiple combinations can be used
49-
'admin' => array(
50-
'password' => 'adminpassword',
51-
),
52-
'guest' => array(
53-
'password' => '',
54-
'servers' => array(1) // Optional list of servers this user can access.
55-
)
56-
),*/
8+
if (!empty($admin_user)) {
9+
$config['login'] = array(
10+
$admin_user => array(
11+
'password' => $admin_pass,
12+
),
13+
);
14+
}
5715

58-
// Use HTML form/cookie-based auth instead of HTTP Basic/Digest auth
59-
'cookie_auth' => false,
16+
$config['servers'] = array();
6017

18+
$prefix = 'REDIS_';
6119

62-
/*'serialization' => array(
63-
'foo*' => array( // Match like KEYS
64-
// Function called when saving to redis.
65-
'save' => function($data) { return json_encode(json_decode($data)); },
66-
// Function called when loading from redis.
67-
'load' => function($data) { return json_encode(json_decode($data), JSON_PRETTY_PRINT); },
68-
),
69-
),*/
20+
$server_name = getenv($prefix . 'NAME');
21+
$server_host = getenv($prefix . 'HOST');
22+
$server_port = getenv($prefix . 'PORT');
23+
$server_auth = getenv($prefix . 'AUTH');
7024

25+
if (empty($server_host)) {
26+
$server_host = "";
27+
}
7128

72-
// You can ignore settings below this point.
29+
if (empty($server_name)) {
30+
$server_name = $server_host;
31+
}
7332

74-
'maxkeylen' => 100,
75-
'count_elements_page' => 100,
33+
if (empty($server_auth)) {
34+
$server_auth = "";
35+
}
7636

77-
// Use the old KEYS command instead of SCAN to fetch all keys.
78-
'keys' => false,
37+
if (empty($server_port)) {
38+
$server_port = 6379;
39+
}
7940

80-
// How many entries to fetch using each SCAN command.
81-
'scansize' => 1000
41+
$config['servers'][] = array(
42+
'name' => $server_name,
43+
'host' => $server_host,
44+
'port' => $server_port,
45+
'filter' => '*',
8246
);
8347

84-
?>
48+
if (!empty($server_auth)) {
49+
$config['servers'][0]['auth'] = $server_auth;
50+
}

0 commit comments

Comments
 (0)