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 30, 2024
1 parent 869b513 commit dd974d0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/migration-5.7/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DB_ROOT_PASSWORD='secret'
DB_USER='testuser'
DB_PASSWORD='password'
DB_DATABASE='testdb'
MYSQL_name='mysql-container'
MYSQL_MIGRATE_name='mysql-container-migrated'
21 changes: 21 additions & 0 deletions examples/migration-5.7/compose-migrate-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
MARIADB_AUTO_UPGRADE: 1
container_name: ${MYSQL_MIGRATE_name}
image: mariadb:lts
volumes:
# MySQL data that we want to migrate
- dbdata:/var/lib/mysql

volumes:
dbdata: {}
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"

services:
mysql:
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
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
- dbdata:/var/lib/mysql
volumes:
dbdata: {}

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 dd974d0

Please sign in to comment.