Skip to content

Latest commit

 

History

History
386 lines (271 loc) · 6.7 KB

File metadata and controls

386 lines (271 loc) · 6.7 KB

Chronos Docker Deployment

Complete Docker deployment configuration for Chronos team task management system.

📦 What's Included

  • MySQL 8.0 - Database server
  • FastAPI Backend - Python backend with automatic health checks
  • Angular Frontend - Production-optimized Nginx web server
  • Docker Compose - One-command deployment

🚀 Quick Start

1. Clone and Configure

cd Chronos

# Copy environment file
cp .env.example .env

# Customize settings (optional)
# Edit .env file with your preferred passwords and ports

2. One-Command Deployment

# Build and start all services
docker-compose up -d --build

3. Access the Application

📋 Prerequisites

  • Docker (version 20.10 or higher)
  • Docker Compose (version 2.0 or higher)
  • At least 2GB of free RAM
  • At least 5GB of free disk space

Verify Installation

# Check Docker version
docker --version

# Check Docker Compose version
docker-compose --version

🔧 Configuration

Environment Variables

Copy .env.example to .env and customize:

# Database
MYSQL_ROOT_PASSWORD=your_secure_password
MYSQL_DATABASE=chronos
MYSQL_USER=chronos
MYSQL_PASSWORD=your_secure_password
MYSQL_PORT=3306

# Backend
BACKEND_PORT=8000

# Frontend
FRONTEND_PORT=80

Ports

Service Container Port Host Port Description
Frontend 80 80 Web interface
Backend 8000 8000 API server
Database 3306 3306 MySQL

🛠️ Common Commands

Start Services

# Start all services
docker-compose up -d

# Start with build
docker-compose up -d --build

# Start specific service
docker-compose up -d backend

Stop Services

# Stop all services
docker-compose down

# Stop and remove volumes (WARNING: deletes data!)
docker-compose down -v

View Logs

# View all logs
docker-compose logs -f

# View specific service logs
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f database

Restart Services

# Restart all services
docker-compose restart

# Restart specific service
docker-compose restart backend

Check Status

# Check running services
docker-compose ps

# Check service health
docker-compose ps

🔍 Health Checks

All services include health checks:

# Check health status
docker-compose ps

# Manual health checks
curl http://localhost/health
curl http://localhost:8000/health

📁 Data Persistence

Data is persisted in Docker volumes:

  • MySQL Data: mysql_data volume
  • Location: /var/lib/docker/volumes/chronos_mysql_data/_data

Backup Database

# Export database
docker exec chronos-database mysqldump -u chronos -pchronos_password chronos > backup.sql

# Import database
docker exec -i chronos-database mysql -u chronos -pchronos_password chronos < backup.sql

🔐 Security

Production Checklist

  • Change default passwords in .env
  • Use strong passwords (min 16 characters)
  • Enable HTTPS/SSL
  • Configure firewall rules
  • Update CORS origins in backend
  • Regular security updates
  • Monitor logs for suspicious activity

HTTPS Setup

For production, use a reverse proxy (Nginx, Traefik) or configure SSL:

# Example with Nginx reverse proxy
services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./certs:/etc/nginx/certs

🐛 Troubleshooting

Backend Won't Start

# Check logs
docker-compose logs backend

# Verify database connection
docker-compose exec backend python -c "import pymysql; pymysql.connect(host='database', user='chronos', password='chronos_password', database='chronos')"

Frontend Shows Blank Page

# Check if backend is accessible
curl http://localhost:8000

# Check nginx configuration
docker exec chronos-frontend nginx -t

Database Connection Issues

# Check if MySQL is running
docker-compose exec database mysql -u chronos -pchronos_password -e "SELECT 1"

# Reset database (WARNING: deletes all data!)
docker-compose down -v
docker-compose up -d database

Port Already in Use

Edit .env and change the port:

FRONTEND_PORT=8080
BACKEND_PORT=8001
MYSQL_PORT=3307

📊 Resource Usage

Monitor Resources

# View resource usage
docker stats

# View container details
docker inspect chronos-backend

Optimize for Production

# Add resource limits in docker-compose.yml
services:
  backend:
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1G
        reservations:
          cpus: '0.5'
          memory: 512M

🔄 Updates

Update Application

# Pull latest changes
git pull

# Rebuild and restart
docker-compose down
docker-compose up -d --build

Update Images

# Pull latest base images
docker-compose pull

# Rebuild
docker-compose up -d --build

🧹 Cleanup

Remove Unused Resources

# Remove stopped containers
docker container prune

# Remove unused volumes
docker volume prune

# Remove unused images
docker image prune

Complete Reset

# Stop and remove everything
docker-compose down -v --rmi all

# Remove build cache
docker builder prune

📈 Monitoring

View Logs in Real-time

docker-compose logs -f

Access Database

# MySQL CLI
docker exec -it chronos-database mysql -u chronos -pchronos_password chronos

# Or from host
mysql -h 127.0.0.1 -P 3306 -u chronos -pchronos_password chronos

Access Backend Shell

docker exec -it chronos-backend bash

Access Frontend Container

docker exec -it chronos-frontend sh

🎯 Production Deployment

Docker Swarm

# Initialize swarm
docker swarm init

# Deploy stack
docker stack deploy -c docker-compose.yml chronos

Kubernetes

For Kubernetes deployment, see kubernetes/ directory (coming soon).

📚 Additional Resources

🆘 Support

If you encounter issues:

  1. Check logs: docker-compose logs
  2. Verify .env configuration
  3. Ensure ports are not in use
  4. Check Docker resource limits
  5. Review troubleshooting section

Back to main README