From f309f16c7b3917ea7beed8cd7814b6a10ed932b3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 23:16:23 -0500 Subject: [PATCH 1/4] refactor: move base image reference to Dockerfile This will allow us to take advantage of automatic update software to auto-pull new versions when they are released to docker hub. --- Dockerfile | 1 + config | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e2a13e --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM postgres:11.6 diff --git a/config b/config index 1a2312f..b0b31fe 100644 --- a/config +++ b/config @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export POSTGRES_IMAGE=${POSTGRES_IMAGE:="postgres"} -export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="11.6"} +export POSTGRES_IMAGE=${POSTGRES_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} +export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} export POSTGRES_ROOT=${POSTGRES_ROOT:="$DOKKU_LIB_ROOT/services/postgres"} export POSTGRES_HOST_ROOT=${POSTGRES_HOST_ROOT:=$POSTGRES_ROOT} From d25e6e6483d5a9c398417bfa961f5fc04de1b748 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Feb 2021 00:11:16 -0500 Subject: [PATCH 2/4] docs: handle image and version correctly --- bin/generate | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/generate b/bin/generate index e91a4f7..0ae59a5 100755 --- a/bin/generate +++ b/bin/generate @@ -474,12 +474,16 @@ def main(): image = None alias = None unimplemented = [] + + with open("Dockerfile") as f: + for line in f.readlines(): + if "FROM " in line: + image, version = line.split(" ")[1].split(":") + image = image.strip() + version = version.strip() + with open("config") as f: for line in f.readlines(): - if "IMAGE_VERSION=${" in line: - version = re.search('"(.+)"', line).group(1) - if "_IMAGE=${" in line: - image = re.search('"(.+)"', line).group(1) if "PLUGIN_COMMAND_PREFIX=" in line: service = re.search('"(.+)"', line).group(1) if "PLUGIN_DEFAULT_ALIAS=" in line: From 832a8045d5b717a17e59f00897b016f74507b0e9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Feb 2021 00:27:52 -0500 Subject: [PATCH 3/4] tests: fix path to Dockerfile when sourcing config for tests --- config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config b/config index b0b31fe..ac21c47 100644 --- a/config +++ b/config @@ -1,6 +1,7 @@ #!/usr/bin/env bash -export POSTGRES_IMAGE=${POSTGRES_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} -export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} +_DIR="$(dirname $0)" +export POSTGRES_IMAGE=${POSTGRES_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} +export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} export POSTGRES_ROOT=${POSTGRES_ROOT:="$DOKKU_LIB_ROOT/services/postgres"} export POSTGRES_HOST_ROOT=${POSTGRES_HOST_ROOT:=$POSTGRES_ROOT} From 5aea44f11c997092eb4dc582c2ea35b1454566a5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Feb 2021 00:45:09 -0500 Subject: [PATCH 4/4] tests: refactor source again --- config | 6 +++--- tests/setup.sh | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config b/config index ac21c47..9ba251b 100644 --- a/config +++ b/config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -_DIR="$(dirname $0)" -export POSTGRES_IMAGE=${POSTGRES_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} -export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} +_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +export POSTGRES_IMAGE=${POSTGRES_IMAGE:="$(awk -F '[ :]' '{print $2}' "${_DIR}/Dockerfile")"} +export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' "${_DIR}/Dockerfile")"} export POSTGRES_ROOT=${POSTGRES_ROOT:="$DOKKU_LIB_ROOT/services/postgres"} export POSTGRES_HOST_ROOT=${POSTGRES_HOST_ROOT:=$POSTGRES_ROOT} diff --git a/tests/setup.sh b/tests/setup.sh index de1f91e..1eacc11 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -19,7 +19,9 @@ echo "Dokku version $DOKKU_VERSION" export DOKKU_LIB_ROOT="/var/lib/dokku" export DOKKU_PLUGINS_ROOT="$DOKKU_LIB_ROOT/plugins/available" -source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" +pushd "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" >/dev/null +source "config" +popd >/dev/null sudo rm -rf "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts" sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \;