Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@

## What is this?

This repository allows you to quickly install the [AdminerEvo](https://docs.adminerevo.org/) fork of the [adminer](https://www.adminer.org/) database manager into a [DDEV](https://ddev.readthedocs.io) project using just `ddev add-on get ddev/ddev-adminer`.
This repository allows you to quickly install the [Adminer](https://www.adminer.org/) database manager into a [DDEV](https://ddev.readthedocs.io) project using just `ddev add-on get ddev/ddev-adminer`.

Adminer is a full-featured database management tool written in PHP. This service
currently ships the [official adminer container](https://hub.docker.com/_/adminer)
with no _external_ plugins. It contains all official plugins and themes and allows
to easily chose one by editing the `docker-compose.adminer.yaml` file after
installation.
Adminer is a full-featured database management tool written in PHP. This service currently ships the [official adminer container](https://hub.docker.com/_/adminer) with no _external_ plugins.

AdminerEvo works with MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Elasticsearch and MongoDB.
Adminer works with MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, and MongoDB.

## Installation

Expand All @@ -22,6 +18,36 @@ ddev add-on get ddev/ddev-adminer && ddev restart

Then you can just `ddev adminer` or use `ddev describe` to get the URL (`https://<project>.ddev.site:9101`).

## Advanced Customization

To change the design:

```sh
# design: https://www.adminer.org/en/#extras
ddev dotenv set .ddev/.env.adminer --adminer-design=dracula
git add .ddev/.env.adminer
ddev add-on get ddev/ddev-adminer && ddev restart
```

To add more plugins:

```sh
# plugins: https://www.adminer.org/en/plugins/
ddev dotenv set .ddev/.env.adminer --adminer-plugins="tables-filter edit-calendar"
git add .ddev/.env.adminer
ddev add-on get ddev/ddev-adminer && ddev restart
```

All possible customization options are listed below (avoid using them if you're unsure):

- `--adminer-design`
- `--adminer-docker-image`
- `--adminer-default-driver`
- `--adminer-default-db`
- `--adminer-default-username`
- `--adminer-default-password`
- `--adminer-plugins`

## What does this add-on do?

* Adds the adminer container as a service
Expand Down
52 changes: 34 additions & 18 deletions docker-compose.adminer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,47 @@
services:
adminer:
container_name: ddev-${DDEV_SITENAME}-adminer
image: shyim/adminerevo:latest
image: ${ADMINER_DOCKER_IMAGE:-adminer:standalone}
environment:
# Use the line below to change the adminer theme.
# - ADMINER_DESIGN=nette
- ADMINER_DEFAULT_SERVER=db
- ADMINER_DEFAULT_USER=db
- ADMINER_DEFAULT_PASSWORD=db
- ADMINER_DEFAULT_DB=db
- ADMINER_PLUGINS=tables-filter
- ADMINER_DEFAULT_DRIVER=${ADMINER_DEFAULT_DRIVER:-${DDEV_DATABASE_FAMILY:-server}}
- ADMINER_DEFAULT_SERVER=${ADMINER_DEFAULT_SERVER:-db}
- ADMINER_DEFAULT_DB=${ADMINER_DEFAULT_DB:-db}
- ADMINER_DEFAULT_USERNAME=${ADMINER_DEFAULT_USERNAME:-db}
- ADMINER_DEFAULT_PASSWORD=${ADMINER_DEFAULT_PASSWORD:-db}
- ADMINER_PLUGINS=${ADMINER_PLUGINS:-tables-filter}
- ADMINER_DESIGN=${ADMINER_DESIGN:-}
- 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"
- ".:/mnt/ddev_config"
- "ddev-global-cache:/mnt/ddev-global-cache"
depends_on:
- db
- db
configs:
- source: adminer-index.php
target: /var/www/html/index.php

web:
links:
- adminer:adminer
configs:
adminer-index.php:
content: |
<?php
if (!count($$_GET)) {
if ($$_ENV['ADMINER_DEFAULT_DRIVER'] === 'mysql') {
$$_ENV['ADMINER_DEFAULT_DRIVER'] = 'server';
} else if ($$_ENV['ADMINER_DEFAULT_DRIVER'] === 'postgres') {
$$_ENV['ADMINER_DEFAULT_DRIVER'] = 'pgsql';
}
$$_POST['auth'] = [
'driver' => $$_ENV['ADMINER_DEFAULT_DRIVER'],
'server' => $$_ENV['ADMINER_DEFAULT_SERVER'],
'db' => $$_ENV['ADMINER_DEFAULT_DB'],
'username' => $$_ENV['ADMINER_DEFAULT_USERNAME'],
'password' => $$_ENV['ADMINER_DEFAULT_PASSWORD'],
];
}
include './adminer.php';
?>
5 changes: 0 additions & 5 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ project_files:
ddev_version_constraint: '>= v1.24.2'

pre_install_actions:
# Ensure we're on DDEV 1.23+. It's required for the `adminer` command (launch by port).
- |
#ddev-nodisplay
#ddev-description:Checking DDEV version
(ddev debug capabilities | grep corepack >/dev/null) || (echo "Please upgrade DDEV to v1.23+ to use this add-on." && false)
- |
#ddev-nodisplay
#ddev-description:Removing old adminer files
Expand Down
11 changes: 8 additions & 3 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ health_checks() {
# Make sure we can hit the 9101 port successfully
run curl -sfI https://${PROJNAME}.ddev.site:9101
assert_success
assert_output --partial "HTTP/2 200"
assert_output --partial "adminer"
assert_output --partial "HTTP/2 302"
assert_output --partial "location: ?server=db&username=db&db=db"

# Make sure `ddev adminer` works
DDEV_DEBUG=true run ddev adminer
Expand Down Expand Up @@ -78,14 +78,19 @@ teardown() {
health_checks
}

@test "install from directory with nonstandard port" {
@test "install from directory with nonstandard port and .env.adminer" {
set -eu -o pipefail
run ddev config --router-http-port=8080 --router-https-port=8443
assert_success
run ddev dotenv set .ddev/.env.adminer --adminer-design="dracula"
assert_success
assert_file_exist .ddev/.env.adminer
echo "# ddev add-on get ${DIR} with project ${PROJNAME} in $(pwd)" >&3
run ddev add-on get "${DIR}"
assert_success
run ddev restart -y
assert_success
run ddev exec -s adminer 'echo $ADMINER_DESIGN'
assert_output "dracula"
health_checks
}