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 mysql container image. #533

Merged
merged 11 commits into from
Jul 12, 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
136 changes: 136 additions & 0 deletions .github/workflows/build-mysql-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: "Build mysql container"

on:
pull_request:
paths:
- "containers/mysql/**"
- ".github/workflows/build-mysql-container.yaml"
- "!**.md"
push:
branches:
- 'main'
paths:
- "containers/mysql/**"
- ".github/workflows/build-mysql-container.yaml"
- "!**.md"

jobs:
tests:
if: github.event_name == 'pull_request'
runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }}
strategy:
matrix:
mysql-version: [ "8.0.18", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32" ]
k8s-version: [ "1.27.1" ]
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
with:
driver: docker # refs: https://github.com/docker/build-push-action/issues/321

- name: Check TAG file
working-directory: containers
run: |
result="$(./tag_exists moco/mysql mysql/${{ matrix.mysql-version }})"
if [ "$result" = ok ]; then
exit 1
fi
echo "TAG=$(cat ./mysql/${{ matrix.mysql-version }}/TAG)" >> $GITHUB_ENV

- uses: docker/build-push-action@v4
with:
context: containers/mysql/${{ matrix.mysql-version }}/.
push: false
load: true
tags: |
ghcr.io/cybozu-go/moco/mysql:${{ env.TAG }}
ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }}

- name: Install Container Structure Tests
run: |
VERSION=v1.15.0
curl -LO "https://storage.googleapis.com/container-structure-test/$VERSION/container-structure-test-linux-amd64" \
&& chmod +x container-structure-test-linux-amd64 \
&& sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
- name: Run Container Structure Tests
run: |
container-structure-test test --image ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} --config ./containers/mysql/${{ matrix.mysql-version }}/container-structure-test.yaml

- name: Create kind cluster
run: kind create cluster --name=moco --config=./e2e/kind-config_actions.yaml --image=kindest/node:v${{ matrix.k8s-version }} --wait 1m

- name: Load mysqld image
run: kind load docker-image ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} --name moco

- name: Install MOCO
run: |
kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml
kubectl -n cert-manager wait --for=condition=available --timeout=180s --all deployments
kubectl apply -f https://github.com/cybozu-go/moco/releases/latest/download/moco.yaml
kubectl -n moco-system wait --for=condition=available --timeout=180s --all deployments

- name: Create MySQLCluster
run: |
cat > mycluster.yaml <<'EOF'
apiVersion: moco.cybozu.com/v1beta1
kind: MySQLCluster
metadata:
namespace: default
name: test
spec:
replicas: 3
podTemplate:
spec:
containers:
- name: mysqld
image: ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }}
volumeClaimTemplates:
- metadata:
name: mysql-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
EOF
kubectl apply -f mycluster.yaml

- name: Wait for MySQLCluster
run: kubectl wait -n default --for=condition=Available mysqlcluster/test --timeout=180s
Comment on lines +98 to +99
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we are only testing until MySQLCluster is ready.
When the MySQL image is pushed to ghcr.io, we will rewrite the E2E manifests and modify it to run the E2E test using the built mysqld image.

https://github.com/cybozu-go/moco/blob/main/e2e/testdata/single.yaml#L26


build:
if: github.ref == 'refs/heads/main'
runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }}
strategy:
matrix:
mysql-version: [ "8.0.18", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32" ]
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/mysql mysql/${{ matrix.mysql-version }})"
if [ "$result" = ok ]; then
exit 1
fi
echo "TAG=$(cat ./mysql/${{ matrix.mysql-version }}/TAG)" >> $GITHUB_ENV

- uses: docker/build-push-action@v4
with:
context: containers/mysql/${{ matrix.mysql-version }}/.
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/cybozu-go/moco/mysql:${{ env.TAG }}
ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }}
1 change: 1 addition & 0 deletions containers/mysql/8.0.18/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
40 changes: 40 additions & 0 deletions containers/mysql/8.0.18/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM quay.io/cybozu/ubuntu-dev:20.04 AS builder

ARG MYSQL_VERSION=8.0.18

RUN apt-get update && apt-get -y install --no-install-recommends \
cmake \
libncurses5-dev \
libjemalloc-dev \
libnuma-dev \
libaio-dev \
pkg-config

RUN cd tmp/ \
&& curl -fsSL -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-${MYSQL_VERSION}.tar.gz \
&& tar -x -z -f mysql-boost-${MYSQL_VERSION}.tar.gz \
&& cd mysql-${MYSQL_VERSION} \
&& mkdir bld \
&& cd bld \
&& cmake .. -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=Release -DWITH_BOOST=$(ls -d ../boost/boost_*) -DWITH_NUMA=1 -DWITH_JEMALLOC=1 -DWITH_PACKAGE_FLAGS=0 \
&& make -j 20 \
&& make install

FROM quay.io/cybozu/ubuntu:20.04

COPY --from=builder /usr/local/mysql/LICENSE /usr/local/mysql/LICENSE
COPY --from=builder /usr/local/mysql/bin /usr/local/mysql/bin
COPY --from=builder /usr/local/mysql/lib /usr/local/mysql/lib
COPY --from=builder /usr/local/mysql/share /usr/local/mysql/share

RUN apt-get update \
&& apt-get install -y --no-install-recommends libjemalloc2 libnuma1 libaio1 \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/lib/mysql \
&& chown -R 10000:10000 /var/lib/mysql

ENV PATH=/usr/local/mysql/bin:"$PATH"
VOLUME /var/lib/mysql
ENTRYPOINT ["mysqld"]
EXPOSE 3306 33060 33062 8080
USER 10000:10000
1 change: 1 addition & 0 deletions containers/mysql/8.0.18/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.18.1
15 changes: 15 additions & 0 deletions containers/mysql/8.0.18/container-structure-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schemaVersion: '2.0.0'
fileExistenceTests:
- name: 'mysqld'
path: '/usr/local/mysql/bin/mysqld'
shouldExist: true
isExecutableBy: 'owner'
- name: 'mysql lib'
path: '/usr/local/mysql/lib'
shouldExist: true
- name: 'mysql share'
path: '/usr/local/mysql/share'
shouldExist: true
- name: 'mysql LICENSE'
path: '/usr/local/mysql/LICENSE'
shouldExist: true
1 change: 1 addition & 0 deletions containers/mysql/8.0.25/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
40 changes: 40 additions & 0 deletions containers/mysql/8.0.25/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM quay.io/cybozu/ubuntu-dev:20.04 AS builder

ARG MYSQL_VERSION=8.0.25

RUN apt-get update && apt-get -y install --no-install-recommends \
cmake \
libncurses5-dev \
libjemalloc-dev \
libnuma-dev \
libaio-dev \
pkg-config

RUN cd tmp/ \
&& curl -fsSL -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-${MYSQL_VERSION}.tar.gz \
&& tar -x -z -f mysql-boost-${MYSQL_VERSION}.tar.gz \
&& cd mysql-${MYSQL_VERSION} \
&& mkdir bld \
&& cd bld \
&& cmake .. -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=Release -DWITH_BOOST=$(ls -d ../boost/boost_*) -DWITH_NUMA=1 -DWITH_JEMALLOC=1 -DWITH_PACKAGE_FLAGS=0 \
&& make -j 20 \
&& make install

FROM quay.io/cybozu/ubuntu:20.04

COPY --from=builder /usr/local/mysql/LICENSE /usr/local/mysql/LICENSE
COPY --from=builder /usr/local/mysql/bin /usr/local/mysql/bin
COPY --from=builder /usr/local/mysql/lib /usr/local/mysql/lib
COPY --from=builder /usr/local/mysql/share /usr/local/mysql/share

RUN apt-get update \
&& apt-get install -y --no-install-recommends libjemalloc2 libnuma1 libaio1 \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/lib/mysql \
&& chown -R 10000:10000 /var/lib/mysql

ENV PATH=/usr/local/mysql/bin:"$PATH"
VOLUME /var/lib/mysql
ENTRYPOINT ["mysqld"]
EXPOSE 3306 33060 33062 8080
USER 10000:10000
1 change: 1 addition & 0 deletions containers/mysql/8.0.25/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.25.1
15 changes: 15 additions & 0 deletions containers/mysql/8.0.25/container-structure-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schemaVersion: '2.0.0'
fileExistenceTests:
- name: 'mysqld'
path: '/usr/local/mysql/bin/mysqld'
shouldExist: true
isExecutableBy: 'owner'
- name: 'mysql lib'
path: '/usr/local/mysql/lib'
shouldExist: true
- name: 'mysql share'
path: '/usr/local/mysql/share'
shouldExist: true
- name: 'mysql LICENSE'
path: '/usr/local/mysql/LICENSE'
shouldExist: true
1 change: 1 addition & 0 deletions containers/mysql/8.0.26/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
40 changes: 40 additions & 0 deletions containers/mysql/8.0.26/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM quay.io/cybozu/ubuntu-dev:20.04 AS builder

ARG MYSQL_VERSION=8.0.26

RUN apt-get update && apt-get -y install --no-install-recommends \
cmake \
libncurses5-dev \
libjemalloc-dev \
libnuma-dev \
libaio-dev \
pkg-config

RUN cd tmp/ \
&& curl -fsSL -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-${MYSQL_VERSION}.tar.gz \
&& tar -x -z -f mysql-boost-${MYSQL_VERSION}.tar.gz \
&& cd mysql-${MYSQL_VERSION} \
&& mkdir bld \
&& cd bld \
&& cmake .. -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=Release -DWITH_BOOST=$(ls -d ../boost/boost_*) -DWITH_NUMA=1 -DWITH_JEMALLOC=1 -DWITH_PACKAGE_FLAGS=0 \
&& make -j 20 \
&& make install

FROM quay.io/cybozu/ubuntu:20.04

COPY --from=builder /usr/local/mysql/LICENSE /usr/local/mysql/LICENSE
COPY --from=builder /usr/local/mysql/bin /usr/local/mysql/bin
COPY --from=builder /usr/local/mysql/lib /usr/local/mysql/lib
COPY --from=builder /usr/local/mysql/share /usr/local/mysql/share

RUN apt-get update \
&& apt-get install -y --no-install-recommends libjemalloc2 libnuma1 libaio1 \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/lib/mysql \
&& chown -R 10000:10000 /var/lib/mysql

ENV PATH=/usr/local/mysql/bin:"$PATH"
VOLUME /var/lib/mysql
ENTRYPOINT ["mysqld"]
EXPOSE 3306 33060 33062 8080
USER 10000:10000
1 change: 1 addition & 0 deletions containers/mysql/8.0.26/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.26.1
15 changes: 15 additions & 0 deletions containers/mysql/8.0.26/container-structure-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schemaVersion: '2.0.0'
fileExistenceTests:
- name: 'mysqld'
path: '/usr/local/mysql/bin/mysqld'
shouldExist: true
isExecutableBy: 'owner'
- name: 'mysql lib'
path: '/usr/local/mysql/lib'
shouldExist: true
- name: 'mysql share'
path: '/usr/local/mysql/share'
shouldExist: true
- name: 'mysql LICENSE'
path: '/usr/local/mysql/LICENSE'
shouldExist: true
1 change: 1 addition & 0 deletions containers/mysql/8.0.27/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
40 changes: 40 additions & 0 deletions containers/mysql/8.0.27/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM quay.io/cybozu/ubuntu-dev:20.04 AS builder

ARG MYSQL_VERSION=8.0.27

RUN apt-get update && apt-get -y install --no-install-recommends \
cmake \
libncurses5-dev \
libjemalloc-dev \
libnuma-dev \
libaio-dev \
pkg-config

RUN cd tmp/ \
&& curl -fsSL -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-${MYSQL_VERSION}.tar.gz \
&& tar -x -z -f mysql-boost-${MYSQL_VERSION}.tar.gz \
&& cd mysql-${MYSQL_VERSION} \
&& mkdir bld \
&& cd bld \
&& cmake .. -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=Release -DWITH_BOOST=$(ls -d ../boost/boost_*) -DWITH_NUMA=1 -DWITH_JEMALLOC=1 -DWITH_PACKAGE_FLAGS=0 \
&& make -j 20 \
&& make install

FROM quay.io/cybozu/ubuntu:20.04

COPY --from=builder /usr/local/mysql/LICENSE /usr/local/mysql/LICENSE
COPY --from=builder /usr/local/mysql/bin /usr/local/mysql/bin
COPY --from=builder /usr/local/mysql/lib /usr/local/mysql/lib
COPY --from=builder /usr/local/mysql/share /usr/local/mysql/share

RUN apt-get update \
&& apt-get install -y --no-install-recommends libjemalloc2 libnuma1 libaio1 \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/lib/mysql \
&& chown -R 10000:10000 /var/lib/mysql

ENV PATH=/usr/local/mysql/bin:"$PATH"
VOLUME /var/lib/mysql
ENTRYPOINT ["mysqld"]
EXPOSE 3306 33060 33062 8080
USER 10000:10000
1 change: 1 addition & 0 deletions containers/mysql/8.0.27/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.27.1
15 changes: 15 additions & 0 deletions containers/mysql/8.0.27/container-structure-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schemaVersion: '2.0.0'
fileExistenceTests:
- name: 'mysqld'
path: '/usr/local/mysql/bin/mysqld'
shouldExist: true
isExecutableBy: 'owner'
- name: 'mysql lib'
path: '/usr/local/mysql/lib'
shouldExist: true
- name: 'mysql share'
path: '/usr/local/mysql/share'
shouldExist: true
- name: 'mysql LICENSE'
path: '/usr/local/mysql/LICENSE'
shouldExist: true
1 change: 1 addition & 0 deletions containers/mysql/8.0.28/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Loading