Skip to content

Commit

Permalink
Build mysqld-exporter container image. (#529)
Browse files Browse the repository at this point in the history
* Build fluent-bit container image.

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

* Remove BRANCH file

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

* Build mysql-exporter container image.

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

* Fix workflow

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

* Fix container link

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

* Use larger_runner_16core

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

* Fix review feedback issues

Signed-off-by: d-kuro <kurosawa7620@gmail.com>

---------

Signed-off-by: d-kuro <kurosawa7620@gmail.com>
  • Loading branch information
d-kuro authored Jun 26, 2023
1 parent df66c09 commit bdb9209
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-mysqld-exporter-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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: ${{ vars.IMAGE_BUILD_RUNNER || '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 moco/mysqld_exporter mysqld_exporter)"
if [ "$result" = ok ]; then
exit 1
fi
echo "TAG=$(cat ./mysqld_exporter/TAG)" >> $GITHUB_ENV
- uses: docker/build-push-action@v4
with:
context: containers/mysqld_exporter/.
platforms: linux/amd64,linux/arm64
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
1 change: 1 addition & 0 deletions containers/mysqld_exporter/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
20 changes: 20 additions & 0 deletions containers/mysqld_exporter/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 8 additions & 0 deletions containers/mysqld_exporter/README.md
Original file line number Diff line number Diff line change
@@ -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 [ghcr.io](https://github.com/cybozu-go/moco/pkgs/container/moco/mysqld_exporter)
1 change: 1 addition & 0 deletions containers/mysqld_exporter/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.14.0.1

0 comments on commit bdb9209

Please sign in to comment.