From ffe51bae075b46e003e49a267c099f274f0aea92 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Sun, 4 Jun 2023 14:38:53 +0200 Subject: [PATCH] feat: migrate the server to MariaDB --- .env.example | 3 ++- docker-compose.prod.yml | 4 ++-- docker-compose.yml | 6 +++--- docker/{mysql => mariadb}/Dockerfile | 4 ++-- docker/{mysql => mariadb}/docker-entrypoint.sh | 0 docker/{mysql => mariadb}/init.sql | 1 + docker/{mysql => mariadb}/my.cnf | 0 7 files changed, 10 insertions(+), 8 deletions(-) rename docker/{mysql => mariadb}/Dockerfile (87%) rename docker/{mysql => mariadb}/docker-entrypoint.sh (100%) rename docker/{mysql => mariadb}/init.sql (99%) rename docker/{mysql => mariadb}/my.cnf (100%) diff --git a/.env.example b/.env.example index 1031c6683..94c47d06e 100644 --- a/.env.example +++ b/.env.example @@ -8,9 +8,10 @@ MAIL_FROM_NAME= MAIL_FROM_ADDRESS= # Database -DB_USER= DB_HOST= +DB_USER= DB_PASSWORD= +DB_ROOT_PASSWORD= DB_CHARSET= # System database diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 8e492480f..04c580729 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -94,12 +94,12 @@ services: mysql: container_name: bigcapital-mysql build: - context: ./docker/mysql + context: ./docker/mariadb environment: - MYSQL_DATABASE=${SYSTEM_DB_NAME} - MYSQL_USER=${DB_USER} - MYSQL_PASSWORD=${DB_PASSWORD} - - MYSQL_ROOT_PASSWORD=${DB_PASSWORD} + - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD} volumes: - mysql:/var/lib/mysql expose: diff --git a/docker-compose.yml b/docker-compose.yml index 324dc5517..11143c063 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,14 +6,14 @@ version: '3.3' services: - mysql: + mariadb: build: - context: ./docker/mysql + context: ./docker/mariadb environment: - MYSQL_DATABASE=${SYSTEM_DB_NAME} - MYSQL_USER=${DB_USER} - MYSQL_PASSWORD=${DB_PASSWORD} - - MYSQL_ROOT_PASSWORD=${DB_PASSWORD} + - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD} volumes: - mysql:/var/lib/mysql expose: diff --git a/docker/mysql/Dockerfile b/docker/mariadb/Dockerfile similarity index 87% rename from docker/mysql/Dockerfile rename to docker/mariadb/Dockerfile index e5b5d2b36..f7b667668 100644 --- a/docker/mysql/Dockerfile +++ b/docker/mariadb/Dockerfile @@ -1,4 +1,4 @@ -FROM mysql:5.7 +FROM mariadb:10.2 USER root ADD my.cnf /etc/mysql/conf.d/my.cnf @@ -17,7 +17,7 @@ ENV MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD COPY ./init.sql /scripts/init.template.sql COPY ./docker-entrypoint.sh /docker-entrypoint-initdb.d/docker-initialize.sh -# The scripts in the docker-entrypoint-initdb.d/ directory are executed as +# The scripts in the `docker-entrypoint-initdb.d/` directory are executed as # the mysql user inside the MySQL Docker container. RUN chown -R mysql:root /docker-entrypoint-initdb.d RUN chown -R mysql:root /scripts diff --git a/docker/mysql/docker-entrypoint.sh b/docker/mariadb/docker-entrypoint.sh similarity index 100% rename from docker/mysql/docker-entrypoint.sh rename to docker/mariadb/docker-entrypoint.sh diff --git a/docker/mysql/init.sql b/docker/mariadb/init.sql similarity index 99% rename from docker/mysql/init.sql rename to docker/mariadb/init.sql index 3110f964c..2cbdec8fb 100644 --- a/docker/mysql/init.sql +++ b/docker/mariadb/init.sql @@ -1,2 +1,3 @@ GRANT ALL PRIVILEGES ON *.* TO '{MYSQL_USER}'@'%' IDENTIFIED BY '{MYSQL_PASSWORD}' WITH GRANT OPTION; + FLUSH PRIVILEGES; \ No newline at end of file diff --git a/docker/mysql/my.cnf b/docker/mariadb/my.cnf similarity index 100% rename from docker/mysql/my.cnf rename to docker/mariadb/my.cnf