Some checks failed
Build and Publish Docker Images / build-and-push (push) Failing after 11m20s
Test Docker Compose Setup / test-compose (push) Failing after 54s
Test Docker Compose Setup / lint-dockerfiles (push) Failing after 30s
Test Docker Compose Setup / validate-compose (push) Failing after 16s
Build and Publish Docker Images / security-scan (push) Has been skipped
Build and Publish Docker Images / notify (push) Failing after 15s
5.5 KiB
5.5 KiB
Docker Setup for UptimeKuma Discord Bot
This guide will help you containerize and run the UptimeKuma Discord Bot using Docker and Docker Compose.
Prerequisites
- Docker and Docker Compose installed on your system
- Uptime Kuma instance running and accessible
- Discord bot application created
Quick Start
-
Clone the repository
git clone <repository-url> cd UptimeKuma-DiscordBot -
Configure environment variables
cp env.example .envEdit the
.envfile with your actual values:# Discord Bot Configuration DISCORD_TOKEN=your_discord_bot_token_here GUILD_ID=your_discord_guild_id_here CHANNEL_ID=your_discord_channel_id_here CLIENT_ID=your_discord_client_id_here UPDATE_TIME=30 # Uptime Kuma Configuration UPTIME_KUMA_URL=https://your-uptime-kuma-instance.com/metrics UPTIME_KUMA_API_KEY=your_uptime_kuma_api_key_here -
Build and start the containers
docker-compose up -d -
Check the logs
docker-compose logs -f
Configuration Details
Environment Variables
| Variable | Description | Required |
|---|---|---|
DISCORD_TOKEN |
Your Discord bot token | Yes |
GUILD_ID |
Discord server (guild) ID | Yes |
CHANNEL_ID |
Discord channel ID for status messages | Yes |
CLIENT_ID |
Discord bot client ID | Yes |
UPDATE_TIME |
Update frequency in seconds (default: 30) | No |
UPTIME_KUMA_URL |
Full URL to your Uptime Kuma metrics endpoint | Yes |
UPTIME_KUMA_API_KEY |
API key from Uptime Kuma dashboard | Yes |
Services
Discord Bot (discord-bot)
- Image: Built from
Bot/Dockerfile - Port: Internal only (no external port)
- Health Check: Node.js process check
- Dependencies:
web-backend
Web Backend (web-backend)
- Image: Built from
Web/Dockerfile - Port: 8080 (external) → 80 (internal)
- Health Check: HTTP endpoint check
- Access:
http://localhost:8080/back-end.php
Docker Commands
Build and Start
# Build and start all services
docker-compose up -d
# Build and start with rebuild
docker-compose up -d --build
# Start specific service
docker-compose up -d discord-bot
Management
# View logs
docker-compose logs -f
docker-compose logs -f discord-bot
docker-compose logs -f web-backend
# Stop services
docker-compose down
# Stop and remove volumes
docker-compose down -v
# Restart services
docker-compose restart
# Update services
docker-compose pull
docker-compose up -d
Debugging
# Execute shell in running container
docker-compose exec discord-bot sh
docker-compose exec web-backend bash
# View container status
docker-compose ps
# View resource usage
docker stats
Troubleshooting
Common Issues
-
Docker build fails with npm ci error
npm error The `npm ci` command can only install with an existing package-lock.jsonSolution: The Dockerfile uses
npm installinstead ofnpm cito work without a lock file. -
Bot not connecting to Discord
- Verify
DISCORD_TOKENis correct - Check Discord bot permissions
- Ensure bot is invited to the server
- Verify
-
Backend not responding
- Verify
UPTIME_KUMA_URLandUPTIME_KUMA_API_KEY - Check Uptime Kuma instance accessibility
- Test API endpoint manually:
curl http://localhost:8080/back-end.php
- Verify
-
Permission errors
- Ensure Docker has proper permissions
- Check file ownership in mounted volumes
-
Container health checks failing
- Check logs:
docker-compose logs - Verify all environment variables are set
- Test individual services
- Check logs:
Health Checks
Both services include health checks:
- Discord Bot: Checks if Node.js process is running
- Web Backend: Checks if PHP endpoint responds
View health status:
docker-compose ps
Logs
Monitor logs in real-time:
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f discord-bot
docker-compose logs -f web-backend
# Last 100 lines
docker-compose logs --tail=100
Security Considerations
- Both containers run as non-root users
- Environment variables are used instead of hardcoded secrets
- Network isolation between services
- Health checks for monitoring
Production Deployment
For production deployment:
- Use Docker secrets for sensitive data
- Set up reverse proxy (nginx/traefik) for SSL termination
- Configure log rotation and monitoring
- Use Docker Swarm or Kubernetes for orchestration
- Set up backup strategies for persistent data
Example Production docker-compose.yml
version: '3.8'
services:
discord-bot:
# ... existing config ...
deploy:
replicas: 1
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
secrets:
- discord_token
- uptime_kuma_api_key
web-backend:
# ... existing config ...
deploy:
replicas: 2
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
secrets:
discord_token:
external: true
uptime_kuma_api_key:
external: true
Support
For issues and questions:
- Check the logs first:
docker-compose logs -f - Verify configuration:
docker-compose config - Test individual services
- Review this documentation
Contributing
When contributing Docker-related changes:
- Test with
docker-compose up -d --build - Verify health checks pass
- Test with different environment configurations
- Update this documentation if needed