From 12c653f98d913879d8217b412bb6564401018ca1 Mon Sep 17 00:00:00 2001 From: nicolas <821778+novalic@users.noreply.github.com> Date: Fri, 24 Mar 2023 06:10:08 +0000 Subject: [PATCH] build(docker-compose): adds database initialization and updates file version and restart policies --- docker-compose.yml | 7 +++++-- docker/db_init/db_setup.sql | 5 +++++ docker/db_setup.sql | 5 ----- 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 docker/db_init/db_setup.sql delete mode 100644 docker/db_setup.sql diff --git a/docker-compose.yml b/docker-compose.yml index a24c1d9..d5961f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,11 @@ -version: "2" +version: "3.7" services: personalpage-db: - image: mariadb + image: mariadb:latest + restart: unless-stopped volumes: + - ./docker/db_init:/docker-entrypoint-initdb.d - db_data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: rootpassword @@ -13,6 +15,7 @@ services: personalpage-service: build: . + restart: unless-stopped depends_on: - personalpage-db command: /env/bin/python /app/manage.py runserver 0.0.0.0:8990 diff --git a/docker/db_init/db_setup.sql b/docker/db_init/db_setup.sql new file mode 100644 index 0000000..359f5eb --- /dev/null +++ b/docker/db_init/db_setup.sql @@ -0,0 +1,5 @@ +CREATE SCHEMA IF NOT EXISTS `personalpage` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +CREATE SCHEMA IF NOT EXISTS `test_personalpage` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +CREATE USER IF NOT EXISTS 'nicolas'@'%' IDENTIFIED BY 'qwerty'; +GRANT ALL PRIVILEGES ON personalpage.* TO 'nicolas'@'%'; +GRANT ALL PRIVILEGES ON test_personalpage.* TO 'nicolas'@'%'; diff --git a/docker/db_setup.sql b/docker/db_setup.sql deleted file mode 100644 index 1195f66..0000000 --- a/docker/db_setup.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE SCHEMA `personalpage` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; -CREATE SCHEMA `test_personalpage` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; -CREATE USER 'nicolas'@'%' IDENTIFIED BY 'qwerty'; -GRANT ALL PRIVILEGES ON personalpage.* TO 'nicolas'@'%'; -GRANT ALL PRIVILEGES ON test_personalpage.* TO 'nicolas'@'%';