From 788e26a254663627755ed52c74bad41647b178ae Mon Sep 17 00:00:00 2001 From: OhMyFelix Date: Wed, 18 Feb 2026 15:22:37 +0000 Subject: [PATCH 1/3] All: support env-based default credentials --- README.md | 24 +++++++++++++ adminer-dg/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-editor/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-full/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-mongo/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-mysql/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-oracle-11/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-oracle-12/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ adminer-postgres/entrypoint.sh | 63 +++++++++++++++++++++++++++++++++ 9 files changed, 528 insertions(+) diff --git a/README.md b/README.md index 3769777..8307d2a 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,30 @@ docker run \ dockette/adminer:dg ``` +You can also prefill login credentials through environment variables. + +- `ADMINER_DRIVER` (example: `pgsql`, `mysql`, `sqlite`, ...) +- `ADMINER_SERVER` (hostname or host:port) +- `ADMINER_USERNAME` +- `ADMINER_PASSWORD` +- `ADMINER_DB` (default database) +- `ADMINER_AUTOLOGIN=1` (submit the login form automatically once) +- `ADMINER_NAME` (overrides page title and heading) + +```sh +docker run \ + --rm \ + -p 8000:80 \ + -e ADMINER_DRIVER=pgsql \ + -e ADMINER_SERVER=postgres \ + -e ADMINER_USERNAME=adminer \ + -e ADMINER_PASSWORD=adminer \ + -e ADMINER_DB=adminer \ + -e ADMINER_AUTOLOGIN=1 \ + -e ADMINER_NAME="Staging DB" \ + dockette/adminer:full +``` + ## Versions | Image | Technologies | Size | Docker Hub | diff --git a/adminer-dg/entrypoint.sh b/adminer-dg/entrypoint.sh index 74f102f..dad07f3 100644 --- a/adminer-dg/entrypoint.sh +++ b/adminer-dg/entrypoint.sh @@ -19,6 +19,69 @@ fi echo "[adminer] Loading Adminer..." +if [ -f /srv/index.php ]; then + cat > /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' +/dev/null || true diff --git a/adminer-mongo/entrypoint.sh b/adminer-mongo/entrypoint.sh index 2b652d2..1e607f6 100644 --- a/adminer-mongo/entrypoint.sh +++ b/adminer-mongo/entrypoint.sh @@ -19,6 +19,69 @@ fi echo "[adminer] Loading Adminer (MongoDB)..." +if [ -f /srv/index.php ]; then + cat > /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + /srv/.adminer-env-bootstrap.php <<'PHP' + (string) getenv('ADMINER_DRIVER'), + 'auth[server]' => (string) getenv('ADMINER_SERVER'), + 'auth[username]' => (string) getenv('ADMINER_USERNAME'), + 'auth[password]' => (string) getenv('ADMINER_PASSWORD'), + 'auth[db]' => (string) getenv('ADMINER_DB'), +]; +$adminerFields = array_filter($adminerFields, static fn ($value) => $value !== ''); +$adminerTitle = (string) getenv('ADMINER_NAME'); +$adminerAutologin = in_array( + strtolower((string) getenv('ADMINER_AUTOLOGIN')), + ['1', 'true', 'yes', 'on'], + true +); + +if (!empty($_GET['file'])) { + return; +} + +if ($adminerFields === [] && $adminerTitle === '' && !$adminerAutologin) { + return; +} + +$adminerPayload = [ + 'fields' => $adminerFields, + 'title' => $adminerTitle, + 'autologin' => $adminerAutologin, +]; + +ob_start(static function ($html) use ($adminerPayload) { + if (!is_string($html) || stripos($html, ''; + + if (stripos($html, '') !== false) { + return preg_replace('~~i', $script . '', $html, 1) ?? ($html . $script); + } + + return $html . $script; +}); +PHP + + if [ ! -f /srv/.adminer-index-original.php ]; then + cp /srv/index.php /srv/.adminer-index-original.php + fi + + cat > /srv/index.php <<'PHP' + Date: Wed, 18 Feb 2026 15:41:52 +0000 Subject: [PATCH 2/3] CI: build on PRs, push only from master --- .github/workflows/docker.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6ab86f1..8d95ddc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,8 +3,9 @@ name: "Docker" on: workflow_dispatch: + pull_request: + push: - branches: ["master"] schedule: - cron: "0 8 * * 1" @@ -74,7 +75,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - if: github.ref == 'refs/heads/master' + if: github.event_name == 'push' && github.ref == 'refs/heads/master' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -104,7 +105,7 @@ jobs: docker stop $CONTAINER_ID - name: Build and push to registry - if: github.ref == 'refs/heads/master' + if: github.event_name == 'push' && github.ref == 'refs/heads/master' uses: docker/build-push-action@v6 with: context: ${{ matrix.context }} From ac2bf74bd69056afaab6fd513f6a4e096b72cd18 Mon Sep 17 00:00:00 2001 From: OhMyFelix Date: Wed, 18 Feb 2026 15:47:14 +0000 Subject: [PATCH 3/3] Revert "CI: build on PRs, push only from master" This reverts commit 2b9bcbb93ca7382d1f35177196eafe3a9e4bc6cf. --- .github/workflows/docker.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8d95ddc..6ab86f1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,9 +3,8 @@ name: "Docker" on: workflow_dispatch: - pull_request: - push: + branches: ["master"] schedule: - cron: "0 8 * * 1" @@ -75,7 +74,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -105,7 +104,7 @@ jobs: docker stop $CONTAINER_ID - name: Build and push to registry - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v6 with: context: ${{ matrix.context }}