From 1bdc2abdea28d4c2380d7e6400690e6f68d23449 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Sun, 5 Jun 2022 14:41:32 -0600 Subject: [PATCH 01/10] Get ddev-login.php working --- adminer/ddev-login.php | 27 +++++++++++++++++++++++++++ docker-compose.adminer.yaml | 15 ++++++++++----- install.yaml | 3 ++- 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 adminer/ddev-login.php diff --git a/adminer/ddev-login.php b/adminer/ddev-login.php new file mode 100644 index 0000000..c2155e5 --- /dev/null +++ b/adminer/ddev-login.php @@ -0,0 +1,27 @@ + + + Date: Sun, 5 Jun 2022 14:50:39 -0600 Subject: [PATCH 02/10] Support https and ddev launch --- commands/host/launch | 75 +++++++++++++++++++++++++++++++++++++ docker-compose.adminer.yaml | 4 +- install.yaml | 1 + 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100755 commands/host/launch diff --git a/commands/host/launch b/commands/host/launch new file mode 100755 index 0000000..4f25dda --- /dev/null +++ b/commands/host/launch @@ -0,0 +1,75 @@ +#!/bin/bash + +## Description: Launch a browser with the current site +## Usage: launch [path] [-p|--phpmyadmin] [-m|--mailhog] +## Example: "ddev launch" or "ddev launch /admin/reports/status/php" or "ddev launch phpinfo.php", for PHPMyAdmin "ddev launch -p", MailHog "ddev launch -m" + +FULLURL=${DDEV_PRIMARY_URL} +HTTPS="" +if [ ${DDEV_PRIMARY_URL%://*} = "https" ]; then HTTPS=true; fi + +while :; do + case ${1:-} in + -h|-\?|--help) + show_help + exit + ;; + -a|--adminer) + if [ "${HTTPS}" = "" ]; then + FULLURL="${FULLURL%:[0-9]*}:9100" + else + FULLURL="${FULLURL%:[0-9]*}:9101" + fi + ;; + -p|--phpmyadmin) + if [ "${HTTPS}" = "" ]; then + FULLURL="${FULLURL%:[0-9]*}:${DDEV_PHPMYADMIN_PORT}" + else + FULLURL="${FULLURL%:[0-9]*}:${DDEV_PHPMYADMIN_HTTPS_PORT}" + fi + ;; + -m|--mailhog) + if [ "${HTTPS}" = "" ]; then + FULLURL="${FULLURL%:[0-9]*}:${DDEV_MAILHOG_PORT}" + else + FULLURL="${FULLURL%:[0-9]*}:${DDEV_MAILHOG_HTTPS_PORT}" + fi + ;; + + --) # End of all options. + shift + break + ;; + -?*) + printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 + ;; + *) # Default case: No more options, so break out of the loop. + break + esac + + shift + done + +if [ -n "${1:-}" ] ; then + if [[ ${1::1} != "/" ]] ; then + FULLURL="${FULLURL}/"; + fi + + FULLURL="${FULLURL}${1}"; +fi + +if [ ! -z ${DDEV_DEBUG:-} ]; then + printf "FULLURL $FULLURL\n" && exit 0 +fi + +case $OSTYPE in + linux-gnu) + xdg-open ${FULLURL} + ;; + "darwin"*) + open ${FULLURL} + ;; + "win*"* | "msys"*) + start ${FULLURL} + ;; +esac diff --git a/docker-compose.adminer.yaml b/docker-compose.adminer.yaml index 502b612..4bb2548 100644 --- a/docker-compose.adminer.yaml +++ b/docker-compose.adminer.yaml @@ -9,8 +9,8 @@ services: - ADMINER_DEFAULT_SERVER=db - ADMINER_PLUGINS=tables-filter - VIRTUAL_HOST=$DDEV_HOSTNAME - - HTTP_EXPOSE=8080:8080 - # Oddly, the value for "mysql" in adminer is "server" + - HTTP_EXPOSE=9100:8080 + - HTTPS_EXPOSE=9101:8080 - DDEV_DBIMAGE - DDEV_DB_NAME=db - DDEV_DB_USER=db diff --git a/install.yaml b/install.yaml index e109ef7..bee24a9 100644 --- a/install.yaml +++ b/install.yaml @@ -4,3 +4,4 @@ name: adminer project_files: - docker-compose.adminer.yaml - adminer +- commands From 85ebd002bd065745720250383c15b9edfa30e98b Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Sun, 5 Jun 2022 14:54:58 -0600 Subject: [PATCH 03/10] Minor updates to README --- README.md | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2051ea8..0eeb115 100644 --- a/README.md +++ b/README.md @@ -12,32 +12,20 @@ with no _external_ plugins. It contains all official plugins and themes and allo to easily chose one by editing the `docker-compose.adminer.yaml` file after installation. -The official container supports: +This currently supports: * MySQL / MariaDB * PostgreSQL -* SQLite -* SimpleDB -* Elasticsearch - -## Why? - -Because you might need something other than MySQL / MariaDB in your DDEV project. We got you covered. ## Installation * `ddev get bserem/ddev-adminer && ddev restart` -## Caveats - -You need to pass database credentials manually for the time being. If you have -any ideas on how to overcome this issue please let me know. +Then you can just `ddev launch -a` or use `ddev describe` to get the URL (`https://.ddev.site:9101`). -Default ddev database credentials are: +## What does this add-on do? -* user `db` -* password `db` -* database `db` +* Adds the adminer container as a service +* Overrides the `ddev launch` command at the project level with a `ddev launch -a` (or `ddev launch --adminer`) option. ---- **Contributed and maintained by [@bserem](https://github.com/bserem).** From d45b6e663b4665bf7e897859587138e33829bef3 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Sun, 5 Jun 2022 16:03:23 -0600 Subject: [PATCH 04/10] Improve tests --- .github/workflows/tests.yml | 7 +++---- commands/host/launch | 4 ++-- tests/test.bats | 17 +++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 88fecea..713ad8a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,7 @@ name: tests on: pull_request: push: - branches: [ master, main ] + branches: [ main ] schedule: - cron: '01 07 * * *' @@ -29,12 +29,11 @@ jobs: strategy: matrix: -# ddev_version: [latest, edge, HEAD] - ddev_version: [edge, HEAD] + ddev_version: [latest, edge, HEAD] # ddev_version: [PR] fail-fast: false - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/commands/host/launch b/commands/host/launch index 4f25dda..e358943 100755 --- a/commands/host/launch +++ b/commands/host/launch @@ -1,8 +1,8 @@ #!/bin/bash ## Description: Launch a browser with the current site -## Usage: launch [path] [-p|--phpmyadmin] [-m|--mailhog] -## Example: "ddev launch" or "ddev launch /admin/reports/status/php" or "ddev launch phpinfo.php", for PHPMyAdmin "ddev launch -p", MailHog "ddev launch -m" +## Usage: launch [path] [-a|--adminer] [-p|--phpmyadmin] [-m|--mailhog] +## Example: "ddev launch" or "ddev launch /admin/reports/status/php" or "ddev launch phpinfo.php", for Adminer "ddev launch -a", MailHog "ddev launch -m" FULLURL=${DDEV_PRIMARY_URL} HTTPS="" diff --git a/tests/test.bats b/tests/test.bats index f76b160..2bd02c3 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -1,13 +1,14 @@ setup() { + mkcert -install >/dev/null export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." export TESTDIR=$(mktemp -d -t testadminer-XXXXXXXXXX) export PROJNAME=testadminer export DDEV_NON_INTERACTIVE=true - ddev delete -Oy ${PROJNAME} || true + ddev delete -Oy ${PROJNAME} >/dev/null || true cd "${TESTDIR}" ddev config --project-name=${PROJNAME} echo ${PROJNAME} - ddev start + ddev start -y >/dev/null } teardown() { @@ -17,12 +18,12 @@ teardown() { } @test "basic installation" { - cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) + set -o pipefail + cd ${TESTDIR} || ( printf "# unable to cd to ${TESTDIR}\n" >&3 && false ) echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 ddev get ${DIR} - ddev restart - # This would be a clearer test, but doesn't work - # status=$(ddev describe | grep adminer | head -1 | awk '{print $4}') - # [[ "${status}" = "OK" ]] - ddev describe | grep adminer | head -1 | awk '{print $4}' + (ddev restart >/dev/null || (echo "# ddev restart returned exit code=%?" >&3 && false)) + ddev help launch | grep adminer >/dev/null +# echo "# Trying curl -s -L -k https://${PROJNAME}.ddev.site:9101/" >&3 + curl --fail -s -L -k https://${PROJNAME}.ddev.site:9101/ | grep 'document.querySelector.*auth.*db' >/dev/null } From eb79b65750e33c56d87b10d2f179e8db93f24699 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Mon, 6 Jun 2022 07:09:23 -0600 Subject: [PATCH 05/10] dummy to start tests From 43cd0da4968f76765a9c0b8a0214a46c28ada52f Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 16 Jun 2022 16:18:56 -0600 Subject: [PATCH 06/10] Files need #ddev-generated in content Signed-off-by: Randy Fay --- .github/workflows/tests.yml | 2 +- adminer/ddev-login.php | 1 + commands/host/launch | 1 + docker-compose.adminer.yaml | 1 + install.yaml | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 713ad8a..80c87a3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - ddev_version: [latest, edge, HEAD] + ddev_version: [latest, HEAD] # ddev_version: [PR] fail-fast: false diff --git a/adminer/ddev-login.php b/adminer/ddev-login.php index c2155e5..ab526d3 100644 --- a/adminer/ddev-login.php +++ b/adminer/ddev-login.php @@ -1,4 +1,5 @@ diff --git a/commands/host/launch b/commands/host/launch index e358943..8a0de34 100755 --- a/commands/host/launch +++ b/commands/host/launch @@ -1,5 +1,6 @@ #!/bin/bash +#ddev-generated ## Description: Launch a browser with the current site ## Usage: launch [path] [-a|--adminer] [-p|--phpmyadmin] [-m|--mailhog] ## Example: "ddev launch" or "ddev launch /admin/reports/status/php" or "ddev launch phpinfo.php", for Adminer "ddev launch -a", MailHog "ddev launch -m" diff --git a/docker-compose.adminer.yaml b/docker-compose.adminer.yaml index 4bb2548..76adc8b 100644 --- a/docker-compose.adminer.yaml +++ b/docker-compose.adminer.yaml @@ -1,3 +1,4 @@ +#ddev-generated version: '3.6' services: adminer: diff --git a/install.yaml b/install.yaml index bee24a9..9a82bfe 100644 --- a/install.yaml +++ b/install.yaml @@ -4,4 +4,4 @@ name: adminer project_files: - docker-compose.adminer.yaml - adminer -- commands +- commands/host/launch From 705316531fcd216f5ead0757379d1a6213bc7917 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 16 Jun 2022 17:11:39 -0600 Subject: [PATCH 07/10] Use build to get php file in there instead of mounting it --- adminer/Dockerfile | 3 +++ docker-compose.adminer.yaml | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 adminer/Dockerfile diff --git a/adminer/Dockerfile b/adminer/Dockerfile new file mode 100644 index 0000000..8a21407 --- /dev/null +++ b/adminer/Dockerfile @@ -0,0 +1,3 @@ +#ddev-generated +FROM adminer:standalone +ADD ddev-login.php /var/www/html/plugins-enabled/ diff --git a/docker-compose.adminer.yaml b/docker-compose.adminer.yaml index 76adc8b..8b53931 100644 --- a/docker-compose.adminer.yaml +++ b/docker-compose.adminer.yaml @@ -3,7 +3,8 @@ version: '3.6' services: adminer: container_name: ddev-${DDEV_SITENAME}-adminer - image: adminer:standalone + build: + context: './adminer' environment: # Use the line below to change the adminer theme. # - ADMINER_DESIGN=nette @@ -19,8 +20,6 @@ services: labels: com.ddev.site-name: ${DDEV_SITENAME} com.ddev.approot: $DDEV_APPROOT - volumes: - - "./adminer:/var/www/html/plugins-enabled" depends_on: - db From 04b0c9464e7a00465e716ae7ecd5d714b18ffd1c Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 16 Jun 2022 17:17:03 -0600 Subject: [PATCH 08/10] rename launch to launcha --- commands/host/{launch => launcha} | 0 install.yaml | 2 +- tests/test.bats | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename commands/host/{launch => launcha} (100%) diff --git a/commands/host/launch b/commands/host/launcha similarity index 100% rename from commands/host/launch rename to commands/host/launcha diff --git a/install.yaml b/install.yaml index 9a82bfe..4a2eb66 100644 --- a/install.yaml +++ b/install.yaml @@ -4,4 +4,4 @@ name: adminer project_files: - docker-compose.adminer.yaml - adminer -- commands/host/launch +- commands/host/launcha diff --git a/tests/test.bats b/tests/test.bats index 2bd02c3..4077209 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -23,7 +23,7 @@ teardown() { echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 ddev get ${DIR} (ddev restart >/dev/null || (echo "# ddev restart returned exit code=%?" >&3 && false)) - ddev help launch | grep adminer >/dev/null + ddev help launcha | grep adminer >/dev/null # echo "# Trying curl -s -L -k https://${PROJNAME}.ddev.site:9101/" >&3 curl --fail -s -L -k https://${PROJNAME}.ddev.site:9101/ | grep 'document.querySelector.*auth.*db' >/dev/null } From 25dddec1fc7bb3000219dac67453eb1bfa421c7a Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Thu, 16 Jun 2022 17:21:10 -0600 Subject: [PATCH 09/10] Change command name to launcha --- commands/host/launcha | 4 ++-- install.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/host/launcha b/commands/host/launcha index 8a0de34..4a6c90e 100755 --- a/commands/host/launcha +++ b/commands/host/launcha @@ -2,8 +2,8 @@ #ddev-generated ## Description: Launch a browser with the current site -## Usage: launch [path] [-a|--adminer] [-p|--phpmyadmin] [-m|--mailhog] -## Example: "ddev launch" or "ddev launch /admin/reports/status/php" or "ddev launch phpinfo.php", for Adminer "ddev launch -a", MailHog "ddev launch -m" +## Usage: launcha [path] [-a|--adminer] [-p|--phpmyadmin] [-m|--mailhog] +## Example: "ddev launcha" or "ddev launcha /admin/reports/status/php" or "ddev launcha phpinfo.php", for Adminer "ddev launcha -a", MailHog "ddev launch -m" FULLURL=${DDEV_PRIMARY_URL} HTTPS="" diff --git a/install.yaml b/install.yaml index 4a2eb66..841b235 100644 --- a/install.yaml +++ b/install.yaml @@ -4,4 +4,6 @@ name: adminer project_files: - docker-compose.adminer.yaml - adminer + +global_files: - commands/host/launcha From a8ee1dcde60a67b3bc5ca8c9aaf711047d841113 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Wed, 22 Jun 2022 12:34:53 -0600 Subject: [PATCH 10/10] Add keepalive-workflow --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 80c87a3..4b6a53e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,3 +75,6 @@ jobs: - name: tests run: bats tests + # keepalive-workflow adds a dummy commit if there's no other action here, keeps + # GitHub from turning off tests after 60 days + - uses: gautamkrishnar/keepalive-workflow@v1