From aa2b3c8b869f49279094a218a14ded8657074061 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..1c2c22e --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM mongo:3.6.15 diff --git a/config b/config index 9b27655..4bcf422 100644 --- a/config +++ b/config @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export MONGO_IMAGE=${MONGO_IMAGE:="mongo"} -export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="3.6.15"} +export MONGO_IMAGE=${MONGO_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} +export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} export MONGO_ROOT=${MONGO_ROOT:="$DOKKU_LIB_ROOT/services/mongo"} export MONGO_HOST_ROOT=${MONGO_HOST_ROOT:=$MONGO_ROOT} From 7c63d5c04d74fda306f57a5fde9e12bd13b4b20c 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 6822c923a0c773ce3100458ab9f9fd1ae439c7f8 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 4bcf422..374c97e 100644 --- a/config +++ b/config @@ -1,6 +1,7 @@ #!/usr/bin/env bash -export MONGO_IMAGE=${MONGO_IMAGE:="$(awk -F '[ :]' '{print $2}' Dockerfile)"} -export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' Dockerfile)"} +_DIR="$(dirname $0)" +export MONGO_IMAGE=${MONGO_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} +export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} export MONGO_ROOT=${MONGO_ROOT:="$DOKKU_LIB_ROOT/services/mongo"} export MONGO_HOST_ROOT=${MONGO_HOST_ROOT:=$MONGO_ROOT} From 4d6972fd4b6dde0c0a190d6c90e7fd0249baa28b 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 374c97e..0fdfa1a 100644 --- a/config +++ b/config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -_DIR="$(dirname $0)" -export MONGO_IMAGE=${MONGO_IMAGE:="$(awk -F '[ :]' '{print $2}' $_DIR/Dockerfile)"} -export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' $_DIR/Dockerfile)"} +_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +export MONGO_IMAGE=${MONGO_IMAGE:="$(awk -F '[ :]' '{print $2}' "${_DIR}/Dockerfile")"} +export MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' "${_DIR}/Dockerfile")"} export MONGO_ROOT=${MONGO_ROOT:="$DOKKU_LIB_ROOT/services/mongo"} export MONGO_HOST_ROOT=${MONGO_HOST_ROOT:=$MONGO_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" \;