diff --git a/db/data.sql b/db/data.sql index 135fba0e..5b5a7840 100644 --- a/db/data.sql +++ b/db/data.sql @@ -5,10 +5,6 @@ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; --- Ensure app DB user has SYSTEM_USER dynamic privilege -GRANT SYSTEM_USER ON *.* TO 'mysql_user'@'%'; -FLUSH PRIVILEGES; - -- ============================================================ -- Table: migrations -- Stores migration history diff --git a/db/docker-compose.yml b/db/docker-compose.yml new file mode 100644 index 00000000..0c982436 --- /dev/null +++ b/db/docker-compose.yml @@ -0,0 +1,44 @@ +version: "3" + +# 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. +services: + database: + container_name: database + restart: unless-stopped + build: + context: . + cap_add: + - SYS_NICE + command: --mysql-native-password=ON + environment: + MYSQL_DATABASE: $MYSQL_DATABASE + MYSQL_USER: $MYSQL_USER + MYSQL_PASSWORD: $MYSQL_PASSWORD + MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD + volumes: + - "db_data:/var/lib/mysql" + networks: + - dokploy-network + + phpmyadmin: + container_name: php-myadmin + restart: unless-stopped + depends_on: + - database + image: phpmyadmin + environment: + PMA_HOST: database + MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD + networks: + - dokploy-network + +volumes: + db_data: + +networks: + dokploy-network: + external: true diff --git a/docker-compose-dokploy.yml b/docker-compose-dokploy.yml new file mode 100644 index 00000000..41f7b059 --- /dev/null +++ b/docker-compose-dokploy.yml @@ -0,0 +1,60 @@ +version: "3.8" + +# client+server only, pointed at an external shared MySQL (see +# db/docker-compose.yml) over Dokploy's dokploy-network. Mirrors +# docker-compose-swarm.yml but targets Dokploy instead of Coolify — +# that file's caddy/elknet/private-network/backend-network networks +# are Coolify-specific and don't exist under Dokploy, so it can't be +# reused as-is without breaking the deployment(s) that already rely +# on it. +services: + client: + image: 'ghcr.io/buzz-code/react-admin-nestjs-client:latest' + container_name: client + restart: unless-stopped + depends_on: + - server + healthcheck: + # 127.0.0.1, not localhost -- localhost resolution is + # unreliable in this image and silently fails the wget + # exec, which Traefik then reads as unhealthy and refuses + # to route to at all. + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:80/"] + interval: 30s + timeout: 10s + start_period: 60s + retries: 3 + environment: + PORT: 80 + REACT_APP_API_URL: 'https://api.$DOMAIN_NAME' + networks: + - dokploy-network + + server: + image: 'ghcr.io/buzz-code/react-admin-nestjs-server:latest' + container_name: server + restart: unless-stopped + healthcheck: + test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"] + interval: 30s + timeout: 10s + start_period: 60s + retries: 3 + environment: + DOMAIN_NAME: $DOMAIN_NAME + MYSQL_HOST: $MYSQL_HOST + MYSQL_USER: $MYSQL_USER + MYSQL_PASSWORD: $MYSQL_PASSWORD + MYSQL_DATABASE: $MYSQL_DATABASE + JWT_SECRET: $JWT_SECRET + ADMIN_USER: $ADMIN_USER + SMTP_USER: $SMTP_USER + SMTP_PASSWORD: $SMTP_PASSWORD + MAINTENANCE_MODE: $MAINTENANCE_MODE + MAINTENANCE_MESSAGE: $MAINTENANCE_MESSAGE + networks: + - dokploy-network + +networks: + dokploy-network: + external: true