diff --git a/.github/actions/action.yml b/.github/actions/action.yml index c6ca256..e722797 100644 --- a/.github/actions/action.yml +++ b/.github/actions/action.yml @@ -1,32 +1,36 @@ -name: Build -description: Build mariadb image +name: push +description: combine multi-arch image and push inputs: version: description: version required: true - tags: - description: image tags - required: true - workdir: - description: working directory - required: true - platform: - description: docker platform + latest: + description: if tag latest required: false - default: linux/amd64 runs: using: "composite" steps: - - name: Build image - env: - MARIADB_VER: ${{ inputs.version }} - TAGS: ${{ inputs.tags }} - PLATFORM: ${{ inputs.platform }} - run: | - set -e - make buildx-build-amd64 - make test - make buildx-build - . $GITHUB_ACTION_PATH/release.sh - shell: bash - working-directory: ${{ inputs.workdir }} + - name: Build image + env: + VERSION: ${{ inputs.version }} + LATEST: ${{ inputs.latest }} + run: | + if [[ "${GITHUB_REF}" == refs/heads/main || "${GITHUB_REF}" == refs/tags/* ]]; then + minor_ver="${VERSION%.*}" + major_ver="${minor_ver%.*}" + + tags=("${minor_ver}" "${major_ver}") + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + stability_tag=("${GITHUB_REF##*/}") + tags=("${minor_ver}-${stability_tag}" "${major_ver}-${stability_tag}") + else + if [[ -n "${LATEST}" ]]; then + tags+=("latest") + fi + fi + + for tag in "${tags[@]}"; do + TAG=${tag} make buildx-imagetools-create + done + fi + shell: bash diff --git a/.github/actions/release.sh b/.github/actions/release.sh deleted file mode 100755 index 89a0b51..0000000 --- a/.github/actions/release.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ "${GITHUB_REF}" == refs/heads/master || "${GITHUB_REF}" == refs/tags/* ]]; then - docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" - - if [[ "${GITHUB_REF}" == refs/tags/* ]]; then - export STABILITY_TAG="${GITHUB_REF##*/}" - fi - - IFS=',' read -ra tags <<< "${TAGS}" - - for tag in "${tags[@]}"; do - make buildx-push TAG="${tag}"; - done -fi diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4adcd2a..0aa5f98 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -10,63 +10,240 @@ on: env: BASE_IMAGE_STABILITY_TAG: 2.15.5 + MARIADB114: '11.4.4' + MARIADB1011: '10.11.10' + MARIADB106: '10.6.20' + MARIADB105: '10.5.27' DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} jobs: - mariadb-114: + mariadb114-build: + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + arch: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + arch: arm64 + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/setup-buildx-action@v3 + - name: build and push + env: + MARIADB_VER: ${{ env.MARIADB114 }} + TAG: 11.4-${{ matrix.arch }} + PLATFORM: ${{ matrix.platform }} + run: | + make buildx-build + make buildx-push + mariadb114-push: runs-on: ubuntu-latest + needs: + - mariadb114-build + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: ./.github/actions + with: + version: ${{ env.MARIADB114 }} + latest: true + + mariadb1011-build: + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + arch: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + arch: arm64 + runs-on: ${{ matrix.runner }} steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - with: - platforms: amd64,arm64 - - uses: docker/setup-buildx-action@v3 - - uses: ./.github/actions - with: - version: '11.4.4' - tags: '11.4,11,latest' - workdir: 11 - platform: linux/amd64,linux/arm64 - mariadb-1011: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/setup-buildx-action@v3 + - name: build and push + env: + MARIADB_VER: ${{ env.MARIADB1011 }} + TAG: 10.11-${{ matrix.arch }} + PLATFORM: ${{ matrix.platform }} + run: | + make buildx-build + make buildx-push + mariadb1011-push: runs-on: ubuntu-latest + needs: + - mariadb1011-build + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: ./.github/actions + with: + version: ${{ env.MARIADB1011 }} + + mariadb106-build: + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + arch: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + arch: arm64 + runs-on: ${{ matrix.runner }} steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - with: - platforms: amd64,arm64 - - uses: docker/setup-buildx-action@v3 - - uses: ./.github/actions - with: - version: '10.11.10' - tags: '10.11,10' - workdir: 10 - platform: linux/amd64,linux/arm64 - mariadb-106: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/setup-buildx-action@v3 + - name: build and push + env: + MARIADB_VER: ${{ env.MARIADB106 }} + TAG: 10.6-${{ matrix.arch }} + PLATFORM: ${{ matrix.platform }} + run: | + make buildx-build + make buildx-push + mariadb106-push: runs-on: ubuntu-latest + needs: + - mariadb106-build + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: ./.github/actions + with: + version: ${{ env.MARIADB106 }} + + mariadb105-build: + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + arch: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + arch: arm64 + runs-on: ${{ matrix.runner }} steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - with: - platforms: amd64,arm64 - - uses: docker/setup-buildx-action@v3 - - uses: ./.github/actions - with: - version: '10.6.20' - tags: '10.6' - workdir: 10 - platform: linux/amd64,linux/arm64 - mariadb-105: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/setup-buildx-action@v3 + - name: build and push + env: + MARIADB_VER: ${{ env.MARIADB105 }} + TAG: 10.5-${{ matrix.arch }} + PLATFORM: ${{ matrix.platform }} + run: | + make buildx-build + make buildx-push + mariadb105-push: runs-on: ubuntu-latest + needs: + - mariadb105-build steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3.2.0 - with: - platforms: amd64,arm64 - - uses: docker/setup-buildx-action@v3 - - uses: ./.github/actions - with: - version: '10.5.27' - tags: '10.5' - workdir: 10 - platform: linux/amd64,linux/arm64 + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: ./.github/actions + with: + version: ${{ env.MARIADB105 }} + +# mariadb-114: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: docker/setup-qemu-action@v3 +# with: +# platforms: amd64,arm64 +# - uses: docker/setup-buildx-action@v3 +# - uses: ./.github/actions +# with: +# version: '11.4.4' +# tags: '11.4,11,latest' +# workdir: 11 +# platform: linux/amd64,linux/arm64 +# mariadb-1011: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: docker/setup-qemu-action@v3 +# with: +# platforms: amd64,arm64 +# - uses: docker/setup-buildx-action@v3 +# - uses: ./.github/actions +# with: +# version: '10.11.10' +# tags: '10.11,10' +# workdir: 10 +# platform: linux/amd64,linux/arm64 +# mariadb-106: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: docker/setup-qemu-action@v3 +# with: +# platforms: amd64,arm64 +# - uses: docker/setup-buildx-action@v3 +# - uses: ./.github/actions +# with: +# version: '10.6.20' +# tags: '10.6' +# workdir: 10 +# platform: linux/amd64,linux/arm64 +# mariadb-105: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: docker/setup-qemu-action@v3.2.0 +# with: +# platforms: amd64,arm64 +# - uses: docker/setup-buildx-action@v3 +# - uses: ./.github/actions +# with: +# version: '10.5.27' +# tags: '10.5' +# workdir: 10 +# platform: linux/amd64,linux/arm64 diff --git a/10/Makefile b/10/Makefile index 9b79fb2..41c6aac 100644 --- a/10/Makefile +++ b/10/Makefile @@ -10,7 +10,7 @@ ALPINE_VER ?= 3.20 NPROC = -PLATFORM ?= linux/arm64 +PLATFORM ?= linux/amd64 ifeq ($(BASE_IMAGE_STABILITY_TAG),) BASE_IMAGE_TAG := $(ALPINE_VER) @@ -29,7 +29,7 @@ endif REPO = wodby/mariadb NAME = mariadb-$(MARIADB_VER_MINOR) -.PHONY: build buildx-build buildx-push buildx-build-amd64 test push shell run start stop logs clean release +.PHONY: build buildx-build buildx-push test push shell run start stop logs clean release default: build @@ -42,19 +42,6 @@ build: --build-arg WSREP_VER=$(WSREP_VER) \ --build-arg NPROC=$(NPROC) ./ -# --load doesn't work with multiple platforms https://github.com/docker/buildx/issues/59 -# we need to save cache to run tests first. -buildx-build-amd64: - docker buildx build --platform linux/amd64 -t $(REPO):$(TAG) \ - --build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \ - --build-arg MARIADB_VER=$(MARIADB_VER) \ - --build-arg MARIADB_VER_MINOR=$(MARIADB_VER_MINOR) \ - --build-arg GALERA_VER=$(GALERA_VER) \ - --build-arg WSREP_VER=$(WSREP_VER) \ - --build-arg NPROC=$(NPROC) \ - --load \ - ./ - buildx-build: docker buildx build --platform $(PLATFORM) -t $(REPO):$(TAG) \ --build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \ @@ -73,6 +60,12 @@ buildx-push: --build-arg WSREP_VER=$(WSREP_VER) \ --build-arg NPROC=$(NPROC) ./ +bulidx-imagetools-create: + docker buildx imagetools create -t $(REPO):$(TAG) \ + $(REPO):$(MARIADB_VER_MINOR)-amd64 \ + $(REPO):$(MARIADB_VER_MINOR)-arm64 +.PHONY: bulidx-imagetools-create + test: cd ./tests && IMAGE=$(REPO):$(TAG) ./run.sh diff --git a/11/Makefile b/11/Makefile index 7f898e0..19d14c4 100644 --- a/11/Makefile +++ b/11/Makefile @@ -29,7 +29,7 @@ endif REPO = wodby/mariadb NAME = mariadb-$(MARIADB_VER_MINOR) -.PHONY: build buildx-build buildx-push buildx-build-amd64 test push shell run start stop logs clean release +.PHONY: build buildx-build buildx-push test push shell run start stop logs clean release default: build @@ -42,19 +42,6 @@ build: --build-arg WSREP_VER=$(WSREP_VER) \ --build-arg NPROC=$(NPROC) ./ -# --load doesn't work with multiple platforms https://github.com/docker/buildx/issues/59 -# we need to save cache to run tests first. -buildx-build-amd64: - docker buildx build --platform linux/amd64 -t $(REPO):$(TAG) \ - --build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \ - --build-arg MARIADB_VER=$(MARIADB_VER) \ - --build-arg MARIADB_VER_MINOR=$(MARIADB_VER_MINOR) \ - --build-arg GALERA_VER=$(GALERA_VER) \ - --build-arg WSREP_VER=$(WSREP_VER) \ - --build-arg NPROC=$(NPROC) \ - --load \ - ./ - buildx-build: docker buildx build --platform $(PLATFORM) -t $(REPO):$(TAG) \ --build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \ @@ -73,6 +60,12 @@ buildx-push: --build-arg WSREP_VER=$(WSREP_VER) \ --build-arg NPROC=$(NPROC) ./ +bulidx-imagetools-create: + docker buildx imagetools create -t $(REPO):$(TAG) \ + $(REPO):$(MARIADB_VER_MINOR)-amd64 \ + $(REPO):$(MARIADB_VER_MINOR)-arm64 +.PHONY: bulidx-imagetools-create + test: cd ./tests && IMAGE=$(REPO):$(TAG) ./run.sh