Skip to content

Commit

Permalink
Build mysql test image for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ngan committed Apr 7, 2024
1 parent 71cf7e4 commit 39932f1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
36 changes: 36 additions & 0 deletions Dockerfile.mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG MYSQL_VERSION

FROM mysql:${MYSQL_VERSION}-debian
# Make all apt-get commands non-interactive. Setting this as an ARG will apply to the entire
# build phase, but not leak into the final image and run phase.
ARG DEBIAN_FRONTEND=noninteractive

# MySQL 5.7 has been EOL'd and is no longer being built by the official mysql docker maintainers:
# https://github.com/docker-library/mysql/pull/1019
# As such, if we want to add to it, we'll need to update the keyring ourselves.
RUN if [ "${MYSQL_MAJOR}" = "5.7" ]; then \
set -eux; \
# pub rsa4096 2023-10-23 [SC] [expires: 2025-10-22]
# BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C
# uid [ unknown] MySQL Release Engineering <mysql-build@oss.oracle.com>
# sub rsa4096 2023-10-23 [E] [expires: 2025-10-22]
key='BCA4 3417 C3B4 85DD 128E C6D4 B7B3 B788 A8D3 785C'; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \
mkdir -p /etc/apt/keyrings; \
gpg --batch --export "$key" > /etc/apt/keyrings/mysql.gpg; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME"; \
fi

# Install the MySQL test package so that we can get test plugins.
# https://github.com/docker-library/mysql/issues/1040
RUN set -eux \
# Install MySQL test package.
&& apt-get update \
&& apt-get install --yes mysql-community-test

# This is the final stage inwhich we copy the plugins from the test stage. Doing it this way allows
# us to not have to install the test package in the final image since we only need the plugins.
FROM mysql:${MYSQL_VERSION}-debian
COPY --from=0 /usr/lib/mysql/plugin/ /usr/lib/mysql/plugin/
20 changes: 13 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
services:
db:
platform: linux/x86_64
image: "mysql:${MYSQL_VERSION}-debian"
image: "ghcr.io/trilogy-libraries/trilogy/ci-mysql:${MYSQL_VERSION}-debian"
command:
- --sql_mode=NO_ENGINE_SUBSTITUTION
- --server-id=1
- --gtid-mode=ON
- --enforce-gtid-consistency=ON
- --log-bin=mysql-bin.log
- --sql_mode=NO_ENGINE_SUBSTITUTION
- --server-id=1
- --gtid-mode=ON
- --enforce-gtid-consistency=ON
- --log-bin=mysql-bin.log
build:
context: .
dockerfile: Dockerfile.mysql
args:
- MYSQL_VERSION=${MYSQL_VERSION}
cache_from:
- ghcr.io/trilogy-libraries/trilogy/ci-mysql:${MYSQL_VERSION}-debian
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: test
MYSQL_HOST: db.local
volumes:
- "./tmp/mysql-certs:/mysql-certs"
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./test/auth_plugins/${MYSQL_VERSION}/auth_test_plugin.so:/usr/lib/mysql/plugin/auth_test_plugin.so
app:
image: ghcr.io/trilogy-libraries/trilogy/ci-app:distro-${DISTRIBUTION_SLUG}-ruby-${RUBY_VERSION}-mysql-${MYSQL_VERSION}
privileged: true
Expand Down
4 changes: 2 additions & 2 deletions script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mkdir tmp/mysql-certs
chmod 777 tmp/mysql-certs

docker compose rm --stop --force --volumes
output_fold "Pull cache image..." docker compose pull app || true
output_fold "Pull cache image..." docker compose pull app db || true
output_fold "Bootstrapping container..." docker compose build
output_fold "Running tests..." docker compose run --rm app
output_fold "Pushing cache image..." docker compose push app || true # Don't fail if push fails
output_fold "Pushing cache image..." docker compose push app db || true # Don't fail if push fails
Binary file removed test/auth_plugins/5.7/auth_test_plugin.so
Binary file not shown.
Binary file removed test/auth_plugins/8.0/auth_test_plugin.so
Binary file not shown.

0 comments on commit 39932f1

Please sign in to comment.