Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build mysqld-exporter container image. #529

Merged
merged 7 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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