Skip to content

Commit

Permalink
MDBF 633: Docker compose file example for MySQL 5.7 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
an3l committed Jan 4, 2024
1 parent 869b513 commit 1e69500
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/migration-5.7/compose-migrate-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"
x-common-variables: &common-variables
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}

services:
mariadb-from-mysql57:
environment:
<<: *common-variables
MARIADB_AUTO_UPGRADE: 1
container_name: ${MYSQL_MIGRATE_name}
image: mariadb:lts
volumes:
# MySQL data that we want to migrate
- ./mysql-volume:/var/lib/mysql
27 changes: 27 additions & 0 deletions examples/migration-5.7/compose-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3"
# This file will be base for mysql8 too
x-common-variables: &common-variables
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}

services:
mysql:
environment: *common-variables
container_name: ${MYSQL_name}
image: mysql:5.7
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 5s
timeout: 3s
retries: 2
start_period: 0s
volumes:
# Preload files for MySQL data
- ./mysql:/docker-entrypoint-initdb.d:z
# We have to save MySQL volume that will be used in upgrade
- ./mysql-volume:/var/lib/mysql

networks:
backend:
3 changes: 3 additions & 0 deletions examples/migration-5.7/mysql/mysql-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS countries;
CREATE TABLE countries(name char(20));
INSERT INTO countries values ("Bosnia & Herzegovina");

0 comments on commit 1e69500

Please sign in to comment.