Prerequisites
- Docker Engine 20.10 or later
- Docker Compose v3.8 or later
- At least 2GB of available RAM
- Port 3000, 3306, and 5556 available on your host machine
Architecture Overview
The Docker Compose setup includes three main services:- knowledgeCheckr: The main Next.js application
- db: MySQL 8.0+ database with pre-initialized schema
- dex: OpenID Connect identity provider for authentication
Quick Start
Create environment file
Create a
.env file in the root directory with the required environment variables. See the Environment Variables page for details.Start the services
- Pull the pre-built images from GitHub Container Registry
- Start the MySQL database with automatic schema initialization
- Start the Dex authentication server
- Launch the KnowledgeCheckr application
Docker Compose Configuration
The defaultdocker-compose.yml configuration:
Building from Source
If you want to build the Docker images locally instead of using pre-built images:Build the application image
- Stage 1: Install dependencies using Yarn
- Stage 2: Build the Next.js application
- Stage 3: Create minimal runtime image with standalone output
Build the database image
- All Drizzle migrations concatenated into a single init script
- Automatic schema initialization on first run
Dockerfile Details
The application Dockerfile (~/workspace/source/Dockerfile:1-49) uses Node.js 24.11.1 Alpine and implements:
Multi-Stage Build
- Package Installer Stage: Installs dependencies with frozen lockfile for reproducible builds
- Builder Stage: Compiles the Next.js application with production optimizations
- Production Stage: Copies only necessary artifacts for minimal image size
Runtime Environment Validation
The production image includes environment validation at runtime:Volume Management
Database Persistence
The MySQL database data is persisted using a named volume:mysql_data directory before upgrading or migrating.
Dex Configuration
The Dex authentication server requires a configuration file:./dex/dex.config.yaml with your Dex configuration.
Port Mapping
| Service | Container Port | Host Port | Purpose |
|---|---|---|---|
| knowledgeCheckr | 3000 | 3000 | Web application |
| db | 3306 | 3305 | MySQL database (external access) |
| dex | 5556 | 5556 | Dex OIDC provider |
Common Commands
View logs
Restart services
Stop and remove containers
Update to latest images
Troubleshooting
Container won’t start
Check the logs for specific error messages:- Missing or invalid environment variables (see validation errors in logs)
- Port conflicts on host machine
- Insufficient system resources
Database connection errors
Verify the database is ready:DATABASE_HOST environment variable matches the database service name in Docker Compose (default: mysql).
Environment validation failures
The application validates all environment variables at startup. Check the error message for specific missing or invalid variables, then update your.env file accordingly.
Production Considerations
Security Best Practices
- Use strong, unique passwords for all database credentials
- Change the
AUTH_SECRETto a securely generated base64 string - Run containers as non-root user where possible
- Keep Docker images updated regularly
- Use Docker secrets for sensitive data instead of environment variables
- Restrict database port exposure (remove port mapping if not needed externally)
Performance Optimization
- Configure MySQL memory settings based on available RAM
- Enable database query caching
- Use a reverse proxy (nginx, Traefik) for SSL termination
- Set appropriate restart policies for automatic recovery
Next Steps
- Configure environment variables
- Set up database migrations
- Configure authentication providers (GitHub, Google, or custom Dex)