From c2ed4b381b2de8cbca2c773a5ba6f2a526dd6619 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 17 May 2023 13:07:09 +0900 Subject: [PATCH 1/7] Build fluent-bit container image. Signed-off-by: d-kuro --- containers/fluent-bit/BRANCH | 1 + containers/tag_branch_consistency | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 containers/fluent-bit/BRANCH create mode 100755 containers/tag_branch_consistency diff --git a/containers/fluent-bit/BRANCH b/containers/fluent-bit/BRANCH new file mode 100644 index 000000000..cd5ac039d --- /dev/null +++ b/containers/fluent-bit/BRANCH @@ -0,0 +1 @@ +2.0 diff --git a/containers/tag_branch_consistency b/containers/tag_branch_consistency new file mode 100755 index 000000000..19366d11b --- /dev/null +++ b/containers/tag_branch_consistency @@ -0,0 +1,23 @@ +#!/bin/sh -e + +if [ $# -eq 0 ]; then + echo "Usage: tag_branch_consistency DIR" + exit 1 +fi + +DIR="$1" + +if [ ! -f "${DIR}"/BRANCH ]; then + echo "Skip because BRANCH not found" + exit 0 +fi + +TAG=$(cat "${DIR}"/TAG) +BRANCH=$(cat "${DIR}"/BRANCH) + +if [ "${TAG}" = $(echo "${BRANCH}"$(echo "${TAG}" | sed -e s/"${BRANCH}"//)) ]; then + exit 0 +fi + +echo "TAG: ${TAG} and BRANCH: ${BRANCH} diverge" +exit 1 From f1f257c33dd02d7ecfa19aef83b565111da52965 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 31 May 2023 12:21:54 +0900 Subject: [PATCH 2/7] Remove BRANCH file Signed-off-by: d-kuro --- containers/fluent-bit/BRANCH | 1 - containers/tag_branch_consistency | 23 ----------------------- 2 files changed, 24 deletions(-) delete mode 100644 containers/fluent-bit/BRANCH delete mode 100755 containers/tag_branch_consistency diff --git a/containers/fluent-bit/BRANCH b/containers/fluent-bit/BRANCH deleted file mode 100644 index cd5ac039d..000000000 --- a/containers/fluent-bit/BRANCH +++ /dev/null @@ -1 +0,0 @@ -2.0 diff --git a/containers/tag_branch_consistency b/containers/tag_branch_consistency deleted file mode 100755 index 19366d11b..000000000 --- a/containers/tag_branch_consistency +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -e - -if [ $# -eq 0 ]; then - echo "Usage: tag_branch_consistency DIR" - exit 1 -fi - -DIR="$1" - -if [ ! -f "${DIR}"/BRANCH ]; then - echo "Skip because BRANCH not found" - exit 0 -fi - -TAG=$(cat "${DIR}"/TAG) -BRANCH=$(cat "${DIR}"/BRANCH) - -if [ "${TAG}" = $(echo "${BRANCH}"$(echo "${TAG}" | sed -e s/"${BRANCH}"//)) ]; then - exit 0 -fi - -echo "TAG: ${TAG} and BRANCH: ${BRANCH} diverge" -exit 1 From 175f61ad30f263bb4cda4d13df11b64edfaa3011 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 17 May 2023 14:09:01 +0900 Subject: [PATCH 3/7] Build mysql-exporter container image. Signed-off-by: d-kuro --- .../build-mysqld-exporter-container.yaml | 63 +++++++++++++++++++ containers/mysqld_exporter/.dockerignore | 1 + containers/mysqld_exporter/Dockerfile | 20 ++++++ containers/mysqld_exporter/README.md | 8 +++ containers/mysqld_exporter/TAG | 1 + 5 files changed, 93 insertions(+) create mode 100644 .github/workflows/build-mysqld-exporter-container.yaml create mode 100644 containers/mysqld_exporter/.dockerignore create mode 100644 containers/mysqld_exporter/Dockerfile create mode 100644 containers/mysqld_exporter/README.md create mode 100644 containers/mysqld_exporter/TAG diff --git a/.github/workflows/build-mysqld-exporter-container.yaml b/.github/workflows/build-mysqld-exporter-container.yaml new file mode 100644 index 000000000..910ed9949 --- /dev/null +++ b/.github/workflows/build-mysqld-exporter-container.yaml @@ -0,0 +1,63 @@ +name: "Build mysqld exporter container" + +on: + pull_request: + paths: + - "containers/mysqld_exporter/**" + - ".github/workflows/build-mysqld-exporter-container.yaml" + - "!**.md" + push: + branches: + - 'main' + paths: + - "containers/mysqld_exporter/**" + - ".github/workflows/build-mysqld-exporter-container.yaml" + - "!**.md" + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Check TAG file + working-directory: containers + run: | + result="$(./tag_exists mysqld_exporter)" + if [ "$result" = ng ]; then + exit 1 + fi + echo "TAG=$(cat ./mysqld_exporter/TAG)" >> $GITHUB_ENV + + - name: Validate consistency between BRANCH and TAG + working-directory: containers + run: | + ./tag_branch_consistency mysqld_exporter + + - uses: docker/build-push-action@v4 + if: github.ref == 'refs/heads/main' + with: + context: containers/fluent-bit/. + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/cybozu-go/moco/mysqld_exporter:${{ env.TAG }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - uses: docker/build-push-action@v4 + if: github.event_name == 'pull_request' + with: + context: containers/fluent-bit/. + platforms: linux/amd64,linux/arm64 + push: false + tags: ghcr.io/cybozu-go/moco/mysqld_exporter:${{ env.TAG }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/containers/mysqld_exporter/.dockerignore b/containers/mysqld_exporter/.dockerignore new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/containers/mysqld_exporter/.dockerignore @@ -0,0 +1 @@ +* diff --git a/containers/mysqld_exporter/Dockerfile b/containers/mysqld_exporter/Dockerfile new file mode 100644 index 000000000..c77627b4c --- /dev/null +++ b/containers/mysqld_exporter/Dockerfile @@ -0,0 +1,20 @@ +# mysqld_exporter container + +# Stage1: build from source +FROM quay.io/cybozu/golang:1.19-jammy AS build + +ARG MYSQLD_EXPORTER_VERSION=v0.14.0 + +RUN git clone -b ${MYSQLD_EXPORTER_VERSION} --depth 1 https://github.com/prometheus/mysqld_exporter \ + && make -C mysqld_exporter build + +# Stage2: setup runtime container +FROM scratch + +COPY --from=build /work/mysqld_exporter/LICENSE /LICENSE +COPY --from=build /work/mysqld_exporter/mysqld_exporter /mysqld_exporter + +USER 10000:10000 +EXPOSE 9104 + +ENTRYPOINT ["/mysqld_exporter"] diff --git a/containers/mysqld_exporter/README.md b/containers/mysqld_exporter/README.md new file mode 100644 index 000000000..10301514e --- /dev/null +++ b/containers/mysqld_exporter/README.md @@ -0,0 +1,8 @@ +# mysqld_exporter + +This directory provides a Dockerfile to build a Docker container that runs [mysqld_exporter](https://github.com/prometheus/mysqld_exporter). + +Docker images +------------- + +Docker images are available on [Quay.io](https://quay.io/repository/cybozu/mysqld_exporter) diff --git a/containers/mysqld_exporter/TAG b/containers/mysqld_exporter/TAG new file mode 100644 index 000000000..e54d09d4e --- /dev/null +++ b/containers/mysqld_exporter/TAG @@ -0,0 +1 @@ +0.14.0.1 From 43304c422ea66ae3a0ebca9d195a69bc56d39f58 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 31 May 2023 12:35:43 +0900 Subject: [PATCH 4/7] Fix workflow Signed-off-by: d-kuro --- .../workflows/build-mysqld-exporter-container.yaml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-mysqld-exporter-container.yaml b/.github/workflows/build-mysqld-exporter-container.yaml index 910ed9949..efa6b376d 100644 --- a/.github/workflows/build-mysqld-exporter-container.yaml +++ b/.github/workflows/build-mysqld-exporter-container.yaml @@ -31,21 +31,16 @@ jobs: - name: Check TAG file working-directory: containers run: | - result="$(./tag_exists mysqld_exporter)" - if [ "$result" = ng ]; then + result="$(./tag_exists moco/mysqld_exporter mysqld_exporter)" + if [ "$result" = ok ]; then exit 1 fi echo "TAG=$(cat ./mysqld_exporter/TAG)" >> $GITHUB_ENV - - name: Validate consistency between BRANCH and TAG - working-directory: containers - run: | - ./tag_branch_consistency mysqld_exporter - - uses: docker/build-push-action@v4 if: github.ref == 'refs/heads/main' with: - context: containers/fluent-bit/. + context: containers/mysqld_exporter/. platforms: linux/amd64,linux/arm64 push: true tags: ghcr.io/cybozu-go/moco/mysqld_exporter:${{ env.TAG }} @@ -55,7 +50,7 @@ jobs: - uses: docker/build-push-action@v4 if: github.event_name == 'pull_request' with: - context: containers/fluent-bit/. + context: containers/mysqld_exporter/. platforms: linux/amd64,linux/arm64 push: false tags: ghcr.io/cybozu-go/moco/mysqld_exporter:${{ env.TAG }} From ba905d1d169f9cbaa83f61e18b8097d7b79b4187 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 7 Jun 2023 11:37:51 +0900 Subject: [PATCH 5/7] Fix container link Signed-off-by: d-kuro --- containers/mysqld_exporter/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/containers/mysqld_exporter/README.md b/containers/mysqld_exporter/README.md index 10301514e..e7b103c07 100644 --- a/containers/mysqld_exporter/README.md +++ b/containers/mysqld_exporter/README.md @@ -5,4 +5,4 @@ This directory provides a Dockerfile to build a Docker container that runs [mysq Docker images ------------- -Docker images are available on [Quay.io](https://quay.io/repository/cybozu/mysqld_exporter) +Docker images are available on [ghcr.io](https://github.com/cybozu-go/moco/pkgs/container/moco%2Fmysqld_exporter) From 89e5ede3c88a51d47d10364ac2906e19819f8db7 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 7 Jun 2023 11:38:11 +0900 Subject: [PATCH 6/7] Use larger_runner_16core Signed-off-by: d-kuro --- .github/workflows/build-mysqld-exporter-container.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-mysqld-exporter-container.yaml b/.github/workflows/build-mysqld-exporter-container.yaml index efa6b376d..085a2d443 100644 --- a/.github/workflows/build-mysqld-exporter-container.yaml +++ b/.github/workflows/build-mysqld-exporter-container.yaml @@ -16,7 +16,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: larger_runner_16core steps: - uses: actions/checkout@v3 - uses: docker/setup-qemu-action@v2 From 7768a77264ab632a7a6b586abb9ff7017b3cb2f3 Mon Sep 17 00:00:00 2001 From: d-kuro Date: Wed, 14 Jun 2023 13:53:33 +0900 Subject: [PATCH 7/7] Fix review feedback issues Signed-off-by: d-kuro --- .../build-mysqld-exporter-container.yaml | 15 ++------------- containers/mysqld_exporter/README.md | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-mysqld-exporter-container.yaml b/.github/workflows/build-mysqld-exporter-container.yaml index 085a2d443..3558a1001 100644 --- a/.github/workflows/build-mysqld-exporter-container.yaml +++ b/.github/workflows/build-mysqld-exporter-container.yaml @@ -16,7 +16,7 @@ on: jobs: build: - runs-on: larger_runner_16core + runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} steps: - uses: actions/checkout@v3 - uses: docker/setup-qemu-action@v2 @@ -38,21 +38,10 @@ jobs: echo "TAG=$(cat ./mysqld_exporter/TAG)" >> $GITHUB_ENV - uses: docker/build-push-action@v4 - if: github.ref == 'refs/heads/main' with: context: containers/mysqld_exporter/. platforms: linux/amd64,linux/arm64 - push: true - tags: ghcr.io/cybozu-go/moco/mysqld_exporter:${{ env.TAG }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - uses: docker/build-push-action@v4 - if: github.event_name == 'pull_request' - with: - context: containers/mysqld_exporter/. - platforms: linux/amd64,linux/arm64 - push: false + push: ${{ github.ref == 'refs/heads/main' }} tags: ghcr.io/cybozu-go/moco/mysqld_exporter:${{ env.TAG }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/containers/mysqld_exporter/README.md b/containers/mysqld_exporter/README.md index e7b103c07..47297fd32 100644 --- a/containers/mysqld_exporter/README.md +++ b/containers/mysqld_exporter/README.md @@ -5,4 +5,4 @@ This directory provides a Dockerfile to build a Docker container that runs [mysq Docker images ------------- -Docker images are available on [ghcr.io](https://github.com/cybozu-go/moco/pkgs/container/moco%2Fmysqld_exporter) +Docker images are available on [ghcr.io](https://github.com/cybozu-go/moco/pkgs/container/moco/mysqld_exporter)