From f1629b8b5154f20cc9cfe393025a4a39575bd5c5 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..460fd01 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM redis:5.0.7 diff --git a/config b/config index 3003469..4062d77 100755 --- a/config +++ b/config @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export REDIS_IMAGE=${REDIS_IMAGE:="redis"} -export REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="5.0.7"} +export REDIS_IMAGE=${REDIS_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} +export REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} export REDIS_ROOT=${REDIS_ROOT:="$DOKKU_LIB_ROOT/services/redis"} export REDIS_HOST_ROOT=${REDIS_HOST_ROOT:=$REDIS_ROOT} From aa8c6489eeb3da7084e0dfbdc9cd3306bd05382e 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 6f392df029fff80e5be0f238179fed2da45b20c0 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 4062d77..84ccc3f 100755 --- a/config +++ b/config @@ -1,6 +1,7 @@ #!/usr/bin/env bash -export REDIS_IMAGE=${REDIS_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} -export REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} +_DIR="$(dirname $0)" +export REDIS_IMAGE=${REDIS_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} +export REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} export REDIS_ROOT=${REDIS_ROOT:="$DOKKU_LIB_ROOT/services/redis"} export REDIS_HOST_ROOT=${REDIS_HOST_ROOT:=$REDIS_ROOT} From 9eca41dcd50c0625bf6f76eceda9d3bae439af2a 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 84ccc3f..d39d036 100755 --- a/config +++ b/config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -_DIR="$(dirname $0)" -export REDIS_IMAGE=${REDIS_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} -export REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} +_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +export REDIS_IMAGE=${REDIS_IMAGE:="$(awk -F '[ :]' '{print $2}' "${_DIR}/Dockerfile")"} +export REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' "${_DIR}/Dockerfile")"} export REDIS_ROOT=${REDIS_ROOT:="$DOKKU_LIB_ROOT/services/redis"} export REDIS_HOST_ROOT=${REDIS_HOST_ROOT:=$REDIS_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" \;