Skip to content

Add standalone db/docker-compose.yml for a shared MySQL - #148

Closed
buzz-code wants to merge 5 commits into
mainfrom
claude/shared-mysql-compose
Closed

buzz-code wants to merge 5 commits into
mainfrom
claude/shared-mysql-compose

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

What

Adds db/docker-compose.yml — just the database + phpmyadmin services, pulled out of the root docker-compose.yml, meant to be deployed on its own and shared by every app instead of each app bundling its own dedicated MySQL.

Why

Came out of deploying attendance on Dokploy: baking a database service into the app's own compose stack means every app gets its own MySQL container, which isn't what's wanted when the goal is one shared MySQL server that all apps connect to (each with its own database + dedicated user on that one server, same as the existing per-project MySQL convention documented in multi-repo-codespace's run-without-docker skill).

This deploys independently, and other apps' compose stacks reach it over the external dokploy-network by its database container name.

Notes for review

  • Root docker-compose.yml / docker-compose-swarm.yml are untouched — this is purely additive, doesn't change how anyone currently deploys the full bundled stack.
  • Uses dokploy-network (Dokploy's shared network) rather than the Coolify-specific caddy/elknet/private-network networks the root compose files use, since this is for the Dokploy deployment path.
  • Heads-up for whoever adds a second app onto this shared MySQL later: container_name: database is hardcoded here (matching the root compose's convention). Fine as the only "database"-named container on dokploy-network today, but a second compose stack that also declares its own database container joining the same shared network would collide — worth a naming convention once there's an actual second consumer.

Generated by Claude Code

claude added 2 commits August 21, 2026 08:52
The GRANT SYSTEM_USER statement hardcoded 'mysql_user' as the
username, breaking any fresh install that uses a different
MYSQL_USER value (fails with 'You are not allowed to create a
user with GRANT' on MySQL 8.4 since that literal user doesn't
exist).

db/init-grants.sh already does this exact grant correctly and
dynamically via ${MYSQL_USER}, so the line in data.sql was both
redundant and the actual cause of the bug. Removing it lets a
fresh install use any DB username.
Extracted the database+phpmyadmin services from the root
docker-compose.yml into their own file, meant to be deployed once
and shared across every app instead of bundling a dedicated MySQL
into each app's own stack. Reaches consumers over the external
dokploy-network.
Copilot AI lite review requested due to automatic review settings August 21, 2026 09:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Add standalone db/docker-compose.yml for deploying MySQL + phpMyAdmin as shared service on dokploy-network, separate from app stack.

Changes:

  • Add new compose file under db/ for standalone DB deployment
  • Configure MySQL + phpMyAdmin to join external dokploy-network

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread db/docker-compose.yml
Comment on lines +3 to +7
# Standalone MySQL + phpMyAdmin, meant to be deployed on its own (not
# bundled into an app's stack) and shared across every app that needs it.
# Each app gets its own database + dedicated user created on this one
# server (see README below) and reaches it over the `dokploy-network`
# external network.
Comment thread db/docker-compose.yml
Comment on lines +12 to +14
build:
context: .
cap_add:
claude added 2 commits August 22, 2026 18:17
Mirrors docker-compose-swarm.yml (client+server, prebuilt ghcr
images) but targets dokploy-network instead of the Coolify-specific
caddy/elknet/private-network/backend-network networks, so it can be
deployed via Dokploy's git-based compose without editing (and
risking) the file the existing Coolify deployment relies on.
The client container was reporting unhealthy indefinitely -- nginx's
own access log never showed a single hit from the healthcheck itself,
meaning the wget exec was failing before ever reaching nginx, not
after. Docker-unhealthy containers get excluded from Traefik's
routing pool entirely, which is why the client's domain returned a
bare 404 with no route at all, unlike the server (healthy, routed
fine).
buzz-code pushed a commit that referenced this pull request Sep 4, 2026
…nv var set, fix dokploy CI trigger to single compose.deploy call

- Cherry-picked PR #148's commits (db/docker-compose.yml, docker-compose-dokploy.yml,
  data.sql GRANT fix, client healthcheck fix) onto this branch without merging main,
  since that PR is still open.
- Added the env vars actual app code reads but weren't wired anywhere: MYSQL_PORT,
  NODE_ENV, PORT, WORKER_ENABLED, JOB_POLL_MS, JOB_WORKER_BATCH, MAIL_WEBHOOK_SECRET,
  YEMOT_LEGACY_ROUTE_DEADLINE, IP_ADDRESS, S3_* (found via process.env grep across
  server + server/shared).
- Replaced the guessed DOKPLOY_CLIENT_WEBHOOK/DOKPLOY_SERVER_WEBHOOK secrets with a
  single dokploy API call (compose.deploy) against the one compose stack that already
  runs client+server together, using a DOKPLOY_API_KEY secret.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019uTSUALnwT3fCG2vCC8SM4
@buzz-code buzz-code closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants