From 5032e8b674ece55fe8eb7914315ba922f0fba968 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 17 Dec 2024 10:30:12 +0100 Subject: [PATCH] new: [mongo] switch to pre-built images with upgrade directory --- mongo/README.org | 57 ++++++++++++++++++++++----- mongo/build/Dockerfile | 19 --------- mongo/metadata.yml | 1 + mongo/upgrade/build/4.0.24/Dockerfile | 4 ++ mongo/upgrade/build/5.0.30/Dockerfile | 4 ++ mongo/upgrade/build/6.0.19/Dockerfile | 4 ++ mongo/upgrade/build/7.0.15/Dockerfile | 4 ++ 7 files changed, 65 insertions(+), 28 deletions(-) delete mode 100644 mongo/build/Dockerfile create mode 100644 mongo/upgrade/build/4.0.24/Dockerfile create mode 100644 mongo/upgrade/build/5.0.30/Dockerfile create mode 100644 mongo/upgrade/build/6.0.19/Dockerfile create mode 100644 mongo/upgrade/build/7.0.15/Dockerfile diff --git a/mongo/README.org b/mongo/README.org index aaa38e7..db1a5a3 100644 --- a/mongo/README.org +++ b/mongo/README.org @@ -9,19 +9,58 @@ Since 4.0.6 based on alpine 3.9, alpine is not packaging mongo anymore. So we use the official version (that is huge). We still must change entrypoint to enforce proper directory paths. -A ``Dockerfile`` is provided for this mean. +*** Build new images -You can fetch latest official tags: -#+begin_quote -docker-tags-fetch mongo -l 10 -f '^[0-9]+\.[0-9]+\.[0-9]+$' -#+end_quote +Get the last upstream images versions with: -change it in docker file, then +#+begin_src sh +actions/upstream-versions -l 10 +#+end_src -#+begin_quote -docker build . -t docker.0k.io/mongo:"$TAG"-myc -#+end_quote +Then use these function to help you manage the ~upgrade/build~ +directory and create the ~*-myc~ images from upstream images: +#+begin_src sh +MONGO_VERSION=$( + docker-tags-fetch nextcloud -l 10 -f "^[0-9]+\.[0-9]+\.[0-9]+$" | + sort -V | + tail -n 1 | + cut -f 1 -d "-" +) + + +mk_build_dir() { + local new_version="$1" VLV VV T + ( + cd upgrade/build + + MONGO_LAST_VERSION=$( + find . -maxdepth 1 -mindepth 1 -type d -regex "./[0-9]+\.[0-9]+\.[0-9]+" -printf "%f\n" | + sort -V | tail -n 1) + + for variant in ""; do + if [ -z "$variant" ]; then + VLV="${MONGO_LAST_VERSION}" + VV="${new_version}" + T="${new_version}-myc" + else + VLV="${MONGO_LAST_VERSION}-$variant" + VV="${new_version}-$variant" + T="${new_version}-myc-$variant" + fi + + cp -r "${VLV}" "${VV}" + + sed -ri "s/FROM mongo:.*/FROM mongo:${new_version}/g" "$VV"/Dockerfile + + docker build "$VV" -t docker.0k.io/mongo:${T} || return 1 + docker push "docker.0k.io/mongo:${T}" || return 1 + done + + ) +} +mk_build_dir "$MONGO_VERSION" +#+end_src ** General Access diff --git a/mongo/build/Dockerfile b/mongo/build/Dockerfile deleted file mode 100644 index 7bd8ef4..0000000 --- a/mongo/build/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## Note: alpine version >= 3.9 is required to get mongodb version 4 -## is a simple copy of alpine:3.9 -FROM docker.0k.io/alpine:3.9 as common - -## mongodb-tools is only required because we expect and use mongodump -## XXXvlab: bash is only required by mongo-backup, we could probably only use sh -RUN apk add --no-cache mongodb mongodb-tools bash - -RUN mkdir -p /var/lib/mongod -RUN chown -R mongodb:mongodb /var/lib/mongod - -VOLUME ["/var/lib/mongodb"] -EXPOSE 27017 28017 - -USER mongodb - -ENTRYPOINT [ "mongod", "--config", "/etc/mongod.conf" ] - - diff --git a/mongo/metadata.yml b/mongo/metadata.yml index 19b777c..5f3f199 100644 --- a/mongo/metadata.yml +++ b/mongo/metadata.yml @@ -1,5 +1,6 @@ summary: "MongoDB server" maintainer: "Valentin Lab " +image: docker.0k.io/mongo:4.0.24-myc data-resources: - /var/lib/mongodb config-resources: diff --git a/mongo/upgrade/build/4.0.24/Dockerfile b/mongo/upgrade/build/4.0.24/Dockerfile new file mode 100644 index 0000000..76ff7df --- /dev/null +++ b/mongo/upgrade/build/4.0.24/Dockerfile @@ -0,0 +1,4 @@ +FROM mongo:4.0.24 + +ENTRYPOINT [ "mongod", "--config", "/etc/mongod.conf" ] + diff --git a/mongo/upgrade/build/5.0.30/Dockerfile b/mongo/upgrade/build/5.0.30/Dockerfile new file mode 100644 index 0000000..308dbd6 --- /dev/null +++ b/mongo/upgrade/build/5.0.30/Dockerfile @@ -0,0 +1,4 @@ +FROM mongo:5.0.30 + +ENTRYPOINT [ "mongod", "--config", "/etc/mongod.conf" ] + diff --git a/mongo/upgrade/build/6.0.19/Dockerfile b/mongo/upgrade/build/6.0.19/Dockerfile new file mode 100644 index 0000000..ea6f359 --- /dev/null +++ b/mongo/upgrade/build/6.0.19/Dockerfile @@ -0,0 +1,4 @@ +FROM mongo:6.0.19 + +ENTRYPOINT [ "mongod", "--config", "/etc/mongod.conf" ] + diff --git a/mongo/upgrade/build/7.0.15/Dockerfile b/mongo/upgrade/build/7.0.15/Dockerfile new file mode 100644 index 0000000..1fe39cd --- /dev/null +++ b/mongo/upgrade/build/7.0.15/Dockerfile @@ -0,0 +1,4 @@ +FROM mongo:7.0.15 + +ENTRYPOINT [ "mongod", "--config", "/etc/mongod.conf" ] +