MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
755 stars 436 forks source link

Add versions.json #516

Closed PhrozenByte closed 1 year ago

PhrozenByte commented 1 year ago

versions.json contains information about the MariaDB versions available in this repo (and therefore also on Docker Hub).

It was inspired by PHP's versions.json, but was adapted to better fit MariaDB's needs. The information in versions.json is currently scattered across the repo and often just accessible by humans, e.g. right now it's impossible to reliably determine the latest full version of containerized MariaDB 10.5 programmatically. The only way is to either fiddle around with sed on the Dockerfile, or to build the container.

This PR also fixes some issues with jq in update.sh. The previous jq script to determine the MariaDB version of a given milestone (mariaversion() function) was a bit weird (recursively searching for a .release_id key even caused my jq to exit with a non-zero status code, causing update.sh to fail; the REST API response has a known structure), so I replaced it. I also switched to jq -r (enabling raw output), so that Bash doesn't have to remove the quotes first. See a57a46c50f8df257c18bfe43cb93bdab1600916f.

versions.json is managed by ./update.sh, see cb3db3887ab1e91a5198dd65daf386645b977152. There's no need to edit this file manually (even when adding/removing milestones), just run ./update.sh. If you pass arguments to update.sh, it will update the entries of the given versions in versions.json only. See b72beb47bb2645dc0d8b1adf34a0d8dae71226b4 for an example.

{
  "11.1": {
    "milestone": "11.1",
    "version": "11.1.1",
    "fullVersion": "1:11.1.1+maria~ubu2204",
    "releaseStatus": "RC",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "11.0": {
    "milestone": "11.0",
    "version": "11.0.2",
    "fullVersion": "1:11.0.2+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.11": {
    "milestone": "10.11",
    "version": "10.11.4",
    "fullVersion": "1:10.11.4+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.10": {
    "milestone": "10.10",
    "version": "10.10.5",
    "fullVersion": "1:10.10.5+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.9": {
    "milestone": "10.9",
    "version": "10.9.7",
    "fullVersion": "1:10.9.7+maria~ubu2204",
    "releaseStatus": "Stable",
    "supportType": "Short Term Support",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.6": {
    "milestone": "10.6",
    "version": "10.6.14",
    "fullVersion": "1:10.6.14+maria~ubu2004",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:focal",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.5": {
    "milestone": "10.5",
    "version": "10.5.21",
    "fullVersion": "1:10.5.21+maria~ubu2004",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:focal",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  },
  "10.4": {
    "milestone": "10.4",
    "version": "10.4.30",
    "fullVersion": "1:10.4.30+maria~ubu2004",
    "releaseStatus": "Stable",
    "supportType": "Long Term Support",
    "base": "ubuntu:focal",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le"
    ]
  },
  "11.2": {
    "milestone": "11.2",
    "version": "11.2.0",
    "fullVersion": "1:11.2.0+maria~ubu2204",
    "releaseStatus": "Alpha",
    "supportType": "Unknown",
    "base": "ubuntu:jammy",
    "arches": [
      "amd64",
      "arm64v8",
      "ppc64le",
      "s390x"
    ]
  }
}
grooverdan commented 1 year ago

Thanks for the contribution and fixing my clunky update.sh.

It looks ok, but I'm still trying understand the actual users of the version.json file. Even by committing here its a day or so out on release day.

Other programmatic ways:

$ podman inspect --format '{{range $key, $value := .Labels}}{{if (eq $key "org.opencontainers.image.version")}}{{$value}}{{end}}{{end}}' mariadb:10.5
10.5.21
$ curl -s https://downloads.mariadb.org/rest-api/mariadb/10.5 | jq  '.releases | keys_unsorted[0]'
"10.5.21"

(also suffers from delay accuracy)

PhrozenByte commented 1 year ago

The idea of versions.json is to provide information about the container images that can be built with the Dockerfiles in this repo (i.e. versions.json is not added to the image, it's purely metadata about this repo). It aids people using these Dockerfiles to build their own images, like myself (I'm not actually using Docker, but Podman resp. building my containers with Buildah, allowing me to easily adapt the Dockerfile to fit my needs).

Accessing the latest MariaDB version is just an example, the same applies to any of the information provided in versions.json, e.g. the available milestones, or the available arches. All this information is available somewhere in this repo (e.g. listing milestones is rather easy, listing arches is not); the idea of versions.json is just to have it in one easily accessible place. The goal is not to impose much maintenance effort on the devs, that's why versions.json is managed by update.sh and doesn't require manual interference.

Personally I need to know the exact MariaDB version to decide whether I need to rebuild my image. Since I'm using the Dockerfile directly, I can't rely on MariaDB's REST API due to said delays, because the REST API might yield a new version that wasn't released in this repo yet. The same is true when pulling the image from Docker Hub to examine the image (like accessing the version label, or the MARIADB_VERSION env variable). All these variants don't provide me the info I need ("what version is built by this Dockerfile"), but somewhat similar, yet different info. A working alternative would be to build the container and then examine the version label, but that would make no sense since I'm about to decide whether I need to build the container - if not, it would have been a total waste of energy. So, right now I'm using the following sed snippet to read the version from the Dockerfile (okay, the regex actually looks a little different, but it's the same principle) - it works, but definitely is no nice solution and very prone to changes:

$ sed -ne 's/^ARG MARIADB_VERSION=\([0-9]*:\)\?\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\([+~-].*\)\?$/\2.\3.\4/p' "./vendor/10.5/Dockerfile"
10.5.21

Adding versions.json just makes these things way easier, simply because update.sh already has all the information needed, it just needs to dump it somewhere.

grooverdan commented 1 year ago

Thank for the explanation.