From 79ba0f1001d5ff4a50eb4da1cfb0a2dd41794f40 Mon Sep 17 00:00:00 2001 From: Peter Siemens Date: Wed, 4 Dec 2024 21:53:55 -0800 Subject: [PATCH] Update mysql configuration --- .gitignore | 2 ++ config/settings/base.py | 2 +- docker-compose.yml | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 2251c0807..542c9ca03 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ gcs-local.json pyvenv.cfg ubyssey/settings*.py + +mysql-data \ No newline at end of file diff --git a/config/settings/base.py b/config/settings/base.py index 059e8c4d6..7ad68a779 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -40,7 +40,7 @@ TIME_ZONE=(str, 'Canada/Pacific'), # SQL defaults - SQL_HOST = (str, 'db'), + SQL_HOST = (str, 'mysql'), SQL_DATABASE = (str, 'ubyssey'), SQL_USER = (str, 'root'), SQL_PASSWORD = (str, 'ubyssey'), diff --git a/docker-compose.yml b/docker-compose.yml index 495372af5..dbd100600 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,18 @@ version: "3.7" services: - db: + mysql: platform: linux/x86_64 image: mysql:8.0 - volumes: - - database:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD: ubyssey MYSQL_DATABASE: ubyssey - ports: - - "3307:3306" + MYSQL_USER: ubyssey + MYSQL_PASSWORD: ${SQL_PASSWORD} + MYSQL_ROOT_PASSWORD: ${SQL_PASSWORD} + volumes: + - ./mysql-data:/var/lib/mysql healthcheck: - test: "/usr/bin/mysql --user=root --password=ubyssey --execute \"SHOW DATABASES;\"" + test: "/usr/bin/mysql --user=ubyssey --password=${SQL_PASSWORD} --execute \"SHOW DATABASES;\"" interval: 2s timeout: 20s retries: 20 @@ -23,16 +23,20 @@ services: bash -c "python manage.py migrate && gunicorn ubyssey.wsgi:application --bind 0.0.0.0:8000" environment: - STATIC_URL: https://storage.googleapis.com/ubyssey-staging/static/ + SQL_HOST: mysql + SQL_USER: root + SQL_PASSWORD: ${SQL_PASSWORD} + SQL_DATABASE: ubyssey GS_ACCESS_KEY_ID: ${GS_ACCESS_KEY_ID} GS_SECRET_ACCESS_KEY: ${GS_SECRET_ACCESS_KEY} + STATIC_URL: https://storage.googleapis.com/ubyssey-staging/static/ GOOGLE_APPLICATION_CREDENTIALS: /run/secrets/GOOGLE_APPLICATION_CREDENTIALS secrets: - GOOGLE_APPLICATION_CREDENTIALS expose: - 8000 depends_on: - db: + mysql: condition: service_healthy restart: true @@ -57,6 +61,3 @@ services: secrets: GOOGLE_APPLICATION_CREDENTIALS: file: ./service-account.json - -volumes: - database: