Skip to content

Commit e130844

Browse files
authored
fix: make ADMINER_DESIGN work, fixes #45, fixes #48 (#50)
1 parent e7fa609 commit e130844

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

docker-compose.adminer.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ services:
2727
- source: ddev-adminer.php
2828
target: /var/www/html/ddev-adminer.php
2929
mode: "0444"
30+
- source: entrypoint.sh
31+
target: /usr/local/bin/entrypoint.sh
32+
mode: "0755"
3033

3134
configs:
3235
ddev-adminer.php:
3336
content: |
3437
<?php
38+
// Let static files be served directly
39+
$$uri = parse_url($$_SERVER['REQUEST_URI'], PHP_URL_PATH);
40+
if (is_file('/var/www/html' . $$uri)) {
41+
return false;
42+
}
43+
3544
if (!count($$_GET)) {
3645
if ($$_ENV['ADMINER_DEFAULT_DRIVER'] === 'mysql') {
3746
$$_ENV['ADMINER_DEFAULT_DRIVER'] = 'server';
@@ -48,3 +57,27 @@ configs:
4857
}
4958
include './index.php';
5059
?>
60+
61+
entrypoint.sh:
62+
content: |
63+
#!/bin/sh
64+
set -e
65+
if [ -n "$$ADMINER_DESIGN" ]; then
66+
# Only create link on initial start, to ensure that explicit changes to
67+
# adminer.css after the container was started once are preserved.
68+
if [ ! -e .adminer-init ]; then
69+
for css_file in adminer.css adminer-dark.css; do
70+
if [ -f "designs/$$ADMINER_DESIGN/$$css_file" ]; then
71+
ln -sf "designs/$$ADMINER_DESIGN/$$css_file" adminer.css
72+
break
73+
fi
74+
done
75+
fi
76+
fi
77+
number=1
78+
for PLUGIN in $$ADMINER_PLUGINS; do
79+
php plugin-loader.php "$$PLUGIN" > plugins-enabled/$$(printf "%03d" $$number)-$$PLUGIN.php
80+
number=$$(($$number+1))
81+
done
82+
touch .adminer-init || true
83+
exec "$$@"

tests/test.bats

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ setup() {
3636
assert_success
3737
run ddev start -y
3838
assert_success
39+
40+
export ADMINER_DESIGN=""
3941
}
4042

4143
health_checks() {
@@ -49,6 +51,20 @@ health_checks() {
4951
DDEV_DEBUG=true run ddev adminer
5052
assert_success
5153
assert_output --partial "FULLURL https://${PROJNAME}.ddev.site:9101"
54+
55+
if [ "${ADMINER_DESIGN}" != "" ]; then
56+
run ddev exec -s adminer 'echo $ADMINER_DESIGN'
57+
assert_output "${ADMINER_DESIGN}"
58+
59+
run curl -sfI https://${PROJNAME}.ddev.site:9101/adminer.css
60+
assert_success
61+
assert_output --partial "HTTP/2 200"
62+
assert_output --partial "content-type: text/css"
63+
64+
run curl -sf https://${PROJNAME}.ddev.site:9101/adminer.css
65+
assert_success
66+
assert_output --partial "${ADMINER_DESIGN}"
67+
fi
5268
}
5369

5470
teardown() {
@@ -86,17 +102,18 @@ teardown() {
86102

87103
@test "install from directory with nonstandard port and .env.adminer" {
88104
set -eu -o pipefail
105+
106+
export ADMINER_DESIGN=dracula
107+
89108
run ddev config --router-http-port=8080 --router-https-port=8443
90109
assert_success
91-
run ddev dotenv set .ddev/.env.adminer --adminer-design="dracula"
110+
run ddev dotenv set .ddev/.env.adminer --adminer-design="${ADMINER_DESIGN}"
92111
assert_success
93112
assert_file_exist .ddev/.env.adminer
94113
echo "# ddev add-on get ${DIR} with project ${PROJNAME} in $(pwd)" >&3
95114
run ddev add-on get "${DIR}"
96115
assert_success
97116
run ddev restart -y
98117
assert_success
99-
run ddev exec -s adminer 'echo $ADMINER_DESIGN'
100-
assert_output "dracula"
101118
health_checks
102119
}

0 commit comments

Comments
 (0)