Docker
This commit is contained in:
4
adminer/plugins-enabled/001-dump-json.php
Normal file
4
adminer/plugins-enabled/001-dump-json.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
require_once('plugins/dump-json.php');
|
||||
|
||||
return new AdminerDumpJson();
|
4
adminer/plugins-enabled/002-edit-foreign.php
Normal file
4
adminer/plugins-enabled/002-edit-foreign.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
require_once('plugins/edit-foreign.php');
|
||||
|
||||
return new AdminerEditForeign();
|
4
adminer/plugins-enabled/003-enum-option.php
Normal file
4
adminer/plugins-enabled/003-enum-option.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
require_once('plugins/enum-option.php');
|
||||
|
||||
return new AdminerEnumOption();
|
4
adminer/plugins-enabled/004-json-column.php
Normal file
4
adminer/plugins-enabled/004-json-column.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
require_once('plugins/json-column.php');
|
||||
|
||||
return new AdminerJsonColumn();
|
8
adminer/plugins-enabled/database-hide.php
Normal file
8
adminer/plugins-enabled/database-hide.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require_once 'plugins/database-hide.php';
|
||||
|
||||
return new AdminerDatabaseHide([
|
||||
'mysql',
|
||||
'information_schema',
|
||||
'performance_schema'
|
||||
]);
|
142
adminer/plugins-enabled/dump-markdown.php
Normal file
142
adminer/plugins-enabled/dump-markdown.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* AdminerDumpMarkdown - dump to MARKDOWN format v0.7 (October 14th, 2020)
|
||||
*
|
||||
* @link https://github.com/fthiella/adminer-plugin-dump-markdown
|
||||
* @author Federico Thiella, https://fthiella.github.io/
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
||||
*
|
||||
*/
|
||||
|
||||
class AdminerDumpMarkdown {
|
||||
private $type = 'markdown';
|
||||
private $format = 'Markdown';
|
||||
|
||||
function _format_value($s, $l, $c) {
|
||||
return (strlen(utf8_decode($s)) > $l) ? substr($s, 0, $l) : $s.str_repeat($c, $l-strlen(utf8_decode($s)));
|
||||
}
|
||||
|
||||
function _map($array, $width, $c) {
|
||||
foreach ($array as $k => &$v) $v = $this->_format_value($v, $width[$k], $c);
|
||||
return $array;
|
||||
}
|
||||
|
||||
function _map_header($array) {
|
||||
foreach ($array as $k => &$v) $v = $k;
|
||||
return $array;
|
||||
}
|
||||
|
||||
function _map_mtable($array) {
|
||||
foreach ($array as $k => &$v) $v = '-';
|
||||
return $array;
|
||||
}
|
||||
|
||||
function _markdown_row($row, $column_width, $separator, $filler) {
|
||||
return implode($separator, $this->_map($row, $column_width, $filler));
|
||||
}
|
||||
|
||||
function _markdown_table($rows, $column_width) {
|
||||
$content = $this->_markdown_row($this->_map_header($rows[0]), $column_width, " | ", " ") . "\n";
|
||||
$content .= $this->_markdown_row($this->_map_mtable($rows[0]), $column_width, "-|-", "-") . "\n";
|
||||
foreach ($rows as $row) {
|
||||
$content .= $this->_markdown_row($row, $column_width, " | ", " ") . "\n";
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
function _bool($value) {
|
||||
return $value == 1 ? 'Yes' : 'No';
|
||||
}
|
||||
|
||||
function dumpFormat() {
|
||||
return array($this->type => $this->format);
|
||||
}
|
||||
|
||||
function dumpDatabase($db) {
|
||||
if ($_POST["format"] == $this->type) {
|
||||
echo '# ' . $db . "\n\n";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* export table structure */
|
||||
function dumpTable($table, $style, $is_view = false) {
|
||||
if ($_POST["format"] == $this->type) {
|
||||
echo '## ' . addcslashes($table, "\n\"\\") . "\n\n";
|
||||
|
||||
if ($style) {
|
||||
echo "### table structure\n\n";
|
||||
|
||||
$field_rows = array();
|
||||
$field_width = (['Column name' => 11, 'Type' => 4, 'Comment' => 7, 'Null' => 4, 'AI' => 2]);
|
||||
|
||||
foreach (fields($table) as $field) {
|
||||
$new_row = [
|
||||
'Column name' => $field['field'],
|
||||
'Type' => $field['full_type'],
|
||||
'Comment' => $field['comment'],
|
||||
'Null' => $this->_bool($field['null']),
|
||||
'AI' => $this->_bool($field['auto_increment'])
|
||||
];
|
||||
array_push($field_rows, $new_row);
|
||||
foreach ($new_row as $key => $val) {
|
||||
$field_width[$key] = max($field_width[$key], strlen(utf8_decode($new_row[$key])));
|
||||
}
|
||||
}
|
||||
echo $this->_markdown_table($field_rows, $field_width);
|
||||
echo "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* export table data */
|
||||
function dumpData($table, $style, $query) {
|
||||
if ($_POST["format"] == $this->type) {
|
||||
|
||||
echo "### table data\n\n";
|
||||
|
||||
$connection = connection();
|
||||
$result = $connection->query($query, 1);
|
||||
if ($result) {
|
||||
$rn = 0;
|
||||
$sample_rows = array();
|
||||
$column_width = array();
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
switch(true) {
|
||||
case $rn==0:
|
||||
foreach ($row as $key => $val) {
|
||||
$column_width[$key] = strlen(utf8_decode($key));
|
||||
}
|
||||
case $rn<100:
|
||||
$sample_rows[$rn]=$row;
|
||||
foreach ($row as $key => $val) {
|
||||
$column_width[$key] = max($column_width[$key], strlen(utf8_decode($row[$key])));
|
||||
}
|
||||
break;
|
||||
case $rn==100:
|
||||
echo $this->_markdown_table($sample_rows, $column_width);
|
||||
default:
|
||||
echo $this->_markdown_row($row, $column_width, " | ", " ") . "\n";
|
||||
}
|
||||
$rn++;
|
||||
}
|
||||
if ($rn<100) {
|
||||
echo $this->_markdown_table($sample_rows, $column_width);
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function dumpHeaders($identifier, $multi_table = false) {
|
||||
if ($_POST["format"] == $this->type) {
|
||||
header("Content-Type: text/text; charset=utf-8");
|
||||
return "md";
|
||||
}
|
||||
}
|
||||
}
|
86
adminer/plugins-enabled/foreign-keys.php
Normal file
86
adminer/plugins-enabled/foreign-keys.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
class AdminerForeignKeys {
|
||||
function head() {
|
||||
?>
|
||||
<script<?php echo nonce(); ?>>
|
||||
document.addEventListener("DOMContentLoaded", function()
|
||||
{
|
||||
collapsable = document.getElementsByClassName('collapsable')
|
||||
|
||||
for (item of collapsable) {
|
||||
item.addEventListener('click', function () {
|
||||
moreDiv = this.parentElement.getElementsByClassName('fk-more')[0]
|
||||
|
||||
if (moreDiv.classList.contains('hidden')) {
|
||||
moreDiv.classList.remove('hidden')
|
||||
this.innerHTML = " [<a>less</a>]"
|
||||
} else {
|
||||
moreDiv.classList.add('hidden')
|
||||
this.innerHTML = " [<a>more</a>]"
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
.collapsable {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function backwardKeys($table, $tableName) {
|
||||
$connection = connection();
|
||||
|
||||
$database = $connection->query('SELECT DATABASE() AS db;')->fetch_assoc();
|
||||
$result = $connection->query(sprintf('SELECT TABLE_NAME,COLUMN_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = \'%s\' AND CONSTRAINT_SCHEMA = \'%s\';', $tableName, $database['db']));
|
||||
|
||||
$backwardKeys = [];
|
||||
$i = 0;
|
||||
|
||||
if ($result) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$backwardKeys[$row['TABLE_NAME'] . $i] = [
|
||||
'tableName' => $row['TABLE_NAME'],
|
||||
'columnName' =>$row['COLUMN_NAME'],
|
||||
'referencedColumnName' =>$row['REFERENCED_COLUMN_NAME'],
|
||||
];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($backwardKeys);
|
||||
|
||||
return $backwardKeys;
|
||||
}
|
||||
|
||||
function backwardKeysPrint($backwardKeys, $row) {
|
||||
$iterator = 0;
|
||||
|
||||
foreach ($backwardKeys as $backwardKey) {
|
||||
$iterator++;
|
||||
$whereLink = where_link(1, $backwardKey['columnName'], $row[$backwardKey['referencedColumnName']]);
|
||||
$link = sprintf('select=%s%s', $backwardKey['tableName'], $whereLink);
|
||||
|
||||
if ($iterator === 2) {
|
||||
echo '<div class="fk-more hidden">';
|
||||
}
|
||||
|
||||
echo sprintf("<a href='%s'>%s</a>%s\n", h(ME . $link), $backwardKey['tableName'], ($iterator === 1 && count($backwardKeys) > 1) ? '<span class="collapsable"> [<a>more</a>]</span>' : '');
|
||||
|
||||
if ($iterator === count($backwardKeys)) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return new AdminerForeignKeys();
|
68
docker-compose.yml
Normal file
68
docker-compose.yml
Normal file
@ -0,0 +1,68 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
backend-proxy:
|
||||
container_name: backend_proxy
|
||||
image: nginx
|
||||
volumes:
|
||||
- ./api/:/app/
|
||||
- ./api/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- ./logs/api/:/var/log/nginx/
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8081:80
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
container_name: backend
|
||||
image: php
|
||||
build:
|
||||
context: ./api
|
||||
dockerfile: PHP.Dockerfile
|
||||
env_file: .db.env
|
||||
volumes:
|
||||
- ./api/:/app/
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
frontend-proxy:
|
||||
container_name: frontend_proxy
|
||||
image: nginx
|
||||
volumes:
|
||||
- ./ui/:/app/
|
||||
- ./ui/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- ./logs/ui/:/var/log/nginx/
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8080:80
|
||||
depends_on:
|
||||
- frontend
|
||||
frontend:
|
||||
container_name: frontend
|
||||
image: php:ui
|
||||
build:
|
||||
context: ./ui
|
||||
dockerfile: PHP.Dockerfile
|
||||
env_file: .ui.env
|
||||
volumes:
|
||||
- ./ui/:/app/
|
||||
|
||||
db:
|
||||
image: mariadb
|
||||
volumes:
|
||||
- database:/var/lib/mysql
|
||||
env_file: .db.env
|
||||
adminer:
|
||||
image: adminer
|
||||
environment:
|
||||
ADMINER_PLUGINS: "dump-json edit-foreign enum-option json-column"
|
||||
ADMINER_DESIGN: "dracula"
|
||||
volumes:
|
||||
- ./adminer/plugins-enabled/:/var/www/html/plugins-enabled/
|
||||
ports:
|
||||
- 8082:8080
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
volumes:
|
||||
database:
|
Reference in New Issue
Block a user