From 6058801b31cc1efeca6299918892b86ba5bed892 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Wed, 1 Jun 2022 04:38:12 -0700 Subject: [PATCH] MDBF-426: Feedback-plugin-backend: Docker compose example using the plugin doesn't work - Update env file, no strings - Implement healtcheck by using `healthcheck` script from MariaDB, needed `mysql` user created by new env var - Implement condition for `depends_on` service using `condition` tag that is only available for 2.1 version (not yet for 3.0) --- docker/.env | 11 ++++++----- docker/docker-compose.yml | 12 +++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docker/.env b/docker/.env index bc47f99..374d906 100644 --- a/docker/.env +++ b/docker/.env @@ -8,6 +8,7 @@ PYTHON_VERSION=3.9 NGINX_VERSION=latest MARIADB_VERSION=10.6 MARIADB_ROOT_PASSWORD=1234 +MARIADB_MYSQL_LOCALHOST_USER=1 # For development purposes, the database data directory and configuration file # are passed from the repository. In production these should be set to where you @@ -19,7 +20,7 @@ MARIADB_CONFDIR=./mariadb/confdir # for your deployed server. DJANGO_ALLOWED_HOSTS=* # This key needs to be set to something proper one in a production deployment. -DJANGO_SECRET_KEY='123' +DJANGO_SECRET_KEY=123 # Any non empty string enables Debug mode for Django DJANGO_DEBUG=True @@ -28,9 +29,9 @@ DJANGO_DEBUG=True # as well as the user name exists. # # There will also be a test_{DJANGO_DB_NAME} database used for running tests. -DJANGO_DB_NAME='feedback_plugin' -DJANGO_DB_USER_NAME='feedback' -DJANGO_DB_USER_PASSWORD='A;p4rqgDt-Mf7L{z' +DJANGO_DB_NAME=feedback_plugin +DJANGO_DB_USER_NAME=feedback +DJANGO_DB_USER_PASSWORD=A;p4rqgDt-Mf7L{z # Control logging level for Django. -DJANGO_LOG_LEVEL='ERROR' +DJANGO_LOG_LEVEL=ERROR diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b877e5a..e2cc68d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '2.1' services: db: build: @@ -13,6 +13,12 @@ services: - DJANGO_DB_NAME - DJANGO_DB_USER_NAME - DJANGO_DB_USER_PASSWORD + - MARIADB_MYSQL_LOCALHOST_USER + healthcheck: + test: /usr/local/bin/healthcheck.sh --su=mysql --connect --innodb_initialized + interval: 3s + timeout: 2s + retries: 3 volumes: - ${MARIADB_DATADIR}:/var/lib/mysql - ${MARIADB_CONFDIR}:/etc/mysql/mariadb.conf.d @@ -40,8 +46,8 @@ services: - static_volume:/app/src/staticfiles - ../src/:/app/src/ depends_on: - - db - + db: + condition: service_healthy nginx: build: context: ./nginx