Skip to content

Commit

Permalink
GH-420: Add Adminer for DDEV
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoturve committed Aug 13, 2024
1 parent 3ac626f commit 431634f
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .ddev/addon-metadata/adminer/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: adminer
repository: ddev/ddev-adminer
version: v0.3.4
install_date: "2024-08-13T10:48:46+03:00"
project_files:
- docker-compose.adminer.yaml
- docker-compose.adminer_norouter.yaml
- adminer
- commands/host/adminer
global_files: []
removal_actions: []
3 changes: 3 additions & 0 deletions .ddev/adminer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ddev-generated
FROM adminer:standalone
ADD ddev-login.php /var/www/html/plugins-enabled/
28 changes: 28 additions & 0 deletions .ddev/adminer/ddev-login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
// #ddev-generated
class DDEVLogin {
function loginForm() {
?>
<script type="text/javascript" <?php echo nonce(); ?>>
addEventListener('load', function () {
// Prevent infinite reload loop when auto login failed.
if (document.querySelector('.error')) {
return
}
let dbimage = '<?php echo $_ENV["DDEV_DBIMAGE"] ?>'
// Default driver is mysql ("server"). We don't want to set it if that's the case.dbimage
// The only other currently supported driver is pgsql
if (!dbimage.includes('mariadb') && !dbimage.includes('mysql')) {
document.querySelector('[name="auth[driver]"]').value = "pgsql"
}
document.querySelector('[name="auth[db]"]').value = '<?php echo $_ENV['DDEV_DB_NAME']; ?>'
document.querySelector('[name="auth[username]"]').value = '<?php echo $_ENV['DDEV_DB_USER']; ?>'
document.querySelector('[name="auth[password]"]').value = '<?php echo $_ENV['DDEV_DB_PASS']; ?>'
document.querySelector('[name="auth[permanent]"]:not(:checked)')?.click()
document.querySelector('[type=submit][value=Login]').click()
});
</script>
<?php
}
}
return new DDEVLogin();
15 changes: 15 additions & 0 deletions .ddev/commands/host/adminer
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

## #ddev-generated: If you want to edit and own this file, remove this line.
## Description: Launch a browser with Adminer
## Usage: adminer
## Example: "ddev adminer"

DDEV_ADMINER_PORT=9100
DDEV_ADMINER_HTTPS_PORT=9101

if [ ${DDEV_PRIMARY_URL%://*} = "http" ] || [ -n "${GITPOD_WORKSPACE_ID:-}" ] || [ "${CODESPACES:-}" = "true" ]; then
ddev launch :$DDEV_ADMINER_PORT
else
ddev launch :$DDEV_ADMINER_HTTPS_PORT
fi
30 changes: 30 additions & 0 deletions .ddev/docker-compose.adminer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ddev-generated
services:
adminer:
container_name: ddev-${DDEV_SITENAME}-adminer
build:
context: './adminer'
environment:
# Use the line below to change the adminer theme.
# - ADMINER_DESIGN=nette
- ADMINER_DEFAULT_SERVER=db
- ADMINER_PLUGINS=tables-filter
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=9100:8080
- HTTPS_EXPOSE=9101:8080
- DDEV_DBIMAGE
- DDEV_DB_NAME=db
- DDEV_DB_USER=db
- DDEV_DB_PASS=db
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
volumes:
- ".:/mnt/ddev_config"
- "ddev-global-cache:/mnt/ddev-global-cache"
depends_on:
- db

web:
links:
- adminer:adminer
4 changes: 4 additions & 0 deletions .ddev/docker-compose.adminer_norouter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ddev-generated
# If omit_containers[ddev-router] then this file will be replaced
# with another with a `ports` statement to directly expose port 8080 to 9100
services: {}

0 comments on commit 431634f

Please sign in to comment.