Skip to content

Docker Containerization with proxy#3562

Closed
uprightbass360 wants to merge 0 commit intoazerothcore:masterfrom
uprightbass360:master
Closed

Docker Containerization with proxy#3562
uprightbass360 wants to merge 0 commit intoazerothcore:masterfrom
uprightbass360:master

Conversation

@uprightbass360
Copy link
Copy Markdown

Docker Containerization

PR from main branch to demonstrate workflow functionality. Previous PR was pruned to a feature branch and ended up hiding workflow and trimmed successes. Due to the cyclical nature of the docker build requiring files which required docker, staging a successful workflow runs outside of master was not possible.

This implementation enables Keira3 to be deployed as a containerized web application alongside existing AzerothCore instances for database administration, while maintaining 100% backward compatibility with existing Electron functionality. I utilized claude code to help speedrun the development, but as a devops dev and a 10 year c# engineer I was able to wire together something I hope you are happy with. Check out uprightbass360/keira3 on dockerhub for a look and https://github.com/uprightbass360/acore-compose for an integrated version. I am going to be using this at home. Thank you for your hard work!

Core Architecture

Hybrid Database Connection System

  • Electron Environment: Direct mysql2 connections (preserved, unchanged)
  • Docker/Web Environment: HTTP API proxy with connection pooling (new)
  • Automatic environment detection and transparent interface

Multi-Service Container Architecture

  • Angular Frontend (nginx, port 8080)
  • Database API Service (Node.js/Express, port 3001)
  • External MySQL Database connectivity
  • Reverse proxy integration with security and performance optimization

Complete Implementation (63 files, 12,042 additions)

Core Docker Infrastructure

  • Multi-stage Dockerfile with production optimizations
  • Docker Compose configurations for various deployment scenarios
  • Complete environment variable management and templates
  • Production-grade startup orchestration scripts

Database API Service (646 lines)

  • Express.js REST API with comprehensive MySQL2 connection pooling
  • HTTP endpoints: /api/database/connect, /api/database/query, /api/database/state
  • Error handling with proper HTTP status codes and categorization
  • Request validation, sanitization, and security measures
  • Graceful shutdown handling and resource cleanup

Enhanced MysqlService Integration

  • Environment-aware dual implementation (Electron + Docker)
  • Transparent API interface - same functionality across all environments
  • Connection pooling and performance optimizations
  • Error handling and retry mechanisms

Comprehensive Testing Suite (1,394 lines)

  • Unit Tests: Core API service functionality (361 lines)
  • Integration Tests: End-to-end API endpoints (588 lines)
  • Connection Pool Tests: Database connectivity and lifecycle (445 lines)
  • Docker-specific Jest configuration and test environment
  • Coverage reporting and CI/CD integration

Production Security & Performance

  • nginx reverse proxy with security headers and CORS configuration
  • Non-root container execution with dedicated user accounts
  • Resource limits, health monitoring, and graceful shutdown
  • Multi-platform builds (AMD64/ARM64) and registry support

CI/CD & Deployment Automation

  • Complete GitHub Actions workflow for Docker builds and deployment
  • Multi-registry support (GitHub Container Registry + DockerHub)
  • Automated testing, security scanning, and health validation
  • Manual workflow dispatch with environment selection
  • Container health check fixes (IPv6/IPv4 localhost resolution)

Key Features Delivered

AzerothCore Integration Ready

  • External MySQL database connectivity for existing AC instances
  • Web-based administration interface accessible from any device
  • Seamless integration with existing Docker infrastructure
  • Production-grade deployment with monitoring and scaling

Developer Experience

  • Zero breaking changes to existing Electron functionality
  • Comprehensive documentation and deployment guides
  • Enhanced testing framework with full coverage
  • Modern CI/CD pipelines with automated workflows

Enterprise Production Ready

  • Security hardened containers with best practices
  • Resource management and performance optimization
  • Health monitoring and observability integration
  • Horizontal scaling and load balancing support

Files Added/Modified

Docker Infrastructure

  • docker/Dockerfile, docker-compose.yml, .dockerignore
  • docker/api/database-api.js, database-api.types.js
  • docker/config/nginx.conf, docker-start.sh
  • docker/scripts/build.sh, deploy.sh
  • docker/.env.example, README.md, STRUCTURE.md

Enhanced Core Services

  • libs/shared/db-layer/src/mysql.service.ts (enhanced)
  • libs/shared/config/src/app.config.ts (extended)
  • apps/keira/src/environments/environment.docker.ts (new)

Testing & Quality Assurance

  • docker/tests/ (complete test suite with Jest configuration)
  • 3 comprehensive test files with full coverage
  • CI/CD integration and coverage reporting

CI/CD & Automation

  • .github/workflows/docker-build-deploy-dockerhub.yml
  • Makefile for build automation
  • Enhanced package.json with Docker dependencies

Documentation

  • Complete documentation suite in docs/
  • Deployment guides, architecture documentation
  • Troubleshooting and configuration references

Migration & Compatibility

  • 100% Backward Compatible: All existing Electron functionality preserved
  • Zero Breaking Changes: Existing configs and workflows continue unchanged
  • Additive Architecture: New Docker capabilities without modification
  • Environment Detection: Automatic switching between Electron and Docker modes

Deployment Scenarios

  1. Standalone Container: Simple docker run with environment variables
  2. Docker Compose: Full orchestration with networking and volumes
  3. AzerothCore Integration: External database connectivity for AC administration
  4. Production Deployment: Multi-container scaling with load balancing

This implementation transforms Keira3 from an Electron-only desktop application
into a flexible, deployable web application while preserving all existing
functionality and adding powerful new deployment capabilities for AzerothCore
database administration.

Ready for production deployment!

@uprightbass360 uprightbass360 changed the title Docker Containerization Docker Containerization with proxy Oct 5, 2025
@FrancescoBorzi
Copy link
Copy Markdown
Collaborator

@uprightbass360 this is huge and will take quite a while to check but meanwhile I just wanted to say thank you for sharing your work!

@uprightbass360
Copy link
Copy Markdown
Author

uprightbass360 commented Oct 12, 2025

I know, I'm sorry its so massive. It definitely can and probably should get broken apart to make its way in. I have a some blind spots as I personally am only using it as a web app. Feel free to cherry pick or let me know if you want me to pr anything specifically. I love the app though and really appreciate what you have made. Also most of the testing was auto generated with claude code, so there may be some weird decisions I can't directly speak to. Feel free to snag the docker image for your own uses or let me know if you need any artifacts. Also authentication is going to need to be changed if it is actually deployed in any non-private way as it autofills auth values.

@FrancescoBorzi
Copy link
Copy Markdown
Collaborator

I know, I'm sorry its so massive. It definitely can and probably should get broken apart to make its way in. I have a some blind spots as I personally am only using it as a web app. Feel free to cherry pick or let me know if you want me to pr anything specifically. I love the app though and really appreciate what you have made. Also most of the testing was auto generated with claude code, so there may be some weird decisions I can't directly speak to. Feel free to snag the docker image for your own uses or let me know if you need any artifacts. Also authentication is going to need to be changed if it is actually deployed in any non-private way as it autofills auth values.

Indeed having it split in small PRs that can be reviewed and merged separately would be great!

@uprightbass360
Copy link
Copy Markdown
Author

Sounds good. I may need a branch to go to on your end so I can start with workflows and tests so that subsequent prs can succeed. Would you be willing to spin me up a feat branch to point to instead of trying to pr to master?

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.

2 participants