From 40a3216cbcc6a9d93ede438164656aa40420d272 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Mon, 10 Aug 2026 10:39:19 -0700 Subject: [PATCH] Add a simone dev service to docker-compose Adds a `simone` service alongside `db` so `docker compose up` brings up a full local dev stack: Django runserver with live reload (source bind-mounted) wired to a MariaDB instance. - Bump db image from mariadb:10.1 to mariadb:12-noble to match production's docker-compose and reduce drift. This also happens to sidestep a bug in mysql-connector-python>=9.6.0 where Django's mysql sql_mode check crashes on a broken @cached_property/@staticmethod stack in DatabaseWrapper.display_name -- MariaDB 12's strict-by-default sql_mode never exercises that code path. - Create the simone db/user on first boot via MYSQL_DATABASE/ MYSQL_USER/MYSQL_PASSWORD. - Add a healthcheck using the image's healthcheck.sh --connect so the simone service doesn't race the DB's first-boot restart cycle. - New simone service: builds from the existing Dockerfile, bind-mounts the repo for live reload, runs migrate then runserver, and sets the env vars needed to boot in dev (dev-only DJANGO_SECRET_KEY, SIMONE_DB_* pointed at db, DJANGO_ALLOWED_HOSTS for localhost, plus the blank API-key vars already mocked by .git_hooks_pre-commit). - Drop the obsolete `version:` key. --- docker-compose.yml | 50 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index afcfba1..f1bc88a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,59 @@ -version: "3.9" # optional since v1.27.0 - volumes: simone-db-data: name: simone-db-data services: db: - image: mariadb:10.1 + image: mariadb:12-noble ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: l3tmein + MYSQL_DATABASE: simone + MYSQL_USER: simone + MYSQL_PASSWORD: l3tmein volumes: - simone-db-data:/var/lib/mysql + healthcheck: + # --connect matters: on first boot mariadb runs init scripts against a + # temporary --skip-networking instance, so a socket-based check would + # report healthy before the real, network-enabled server (and the + # `simone` db/user it creates) is actually up. + test: ["CMD", "healthcheck.sh", "--connect"] + interval: 5s + timeout: 5s + retries: 20 + + simone: + build: . + command: sh -c "python manage.py migrate --no-input && python manage.py runserver 0.0.0.0:8000" + ports: + - "8000:8000" + volumes: + - .:/app:z + environment: + ENV: dev + # Dev-only secret, not for production use. + DJANGO_SECRET_KEY: django-insecure-dev-only-not-for-production + DJANGO_ALLOWED_HOSTS: "localhost;127.0.0.1" + SIMONE_DB_NAME: simone + SIMONE_DB_USER: simone + SIMONE_DB_PASSWORD: l3tmein + SIMONE_DB_HOST: db + SIMONE_DB_PORT: "3306" + SLACK_BOT_TOKEN: "" + SLACK_SIGNING_SECRET: "" + # Blank is fine everywhere above, but Dispatcher builds slack_bolt's + # OAuthSettings unconditionally at import time and it rejects a blank + # client_id/client_secret, so these two need *some* non-empty value. + SLACK_CLIENT_ID: "dev" + SLACK_CLIENT_SECRET: "dev" + ALPHA_VANTAGE_KEY: "" + WSJ_QUOTES_CKEY: "" + WSJ_QUOTES_ENTITLEMENT_TOKEN: "" + OPEN_WEATHER_MAP_APP_ID: "" + OPENVERSE_CLIENT_ID: "" + OPENVERSE_CLIENT_SECRET: "" + depends_on: + db: + condition: service_healthy