7.9 KiB
7.9 KiB
✅ Docker Solution - Files Created
📦 Complete Docker Deployment Package
Your Flask application has been packaged into a complete Docker solution. Here's everything that was created:
Core Docker Files
/srv/quality_recticel/
├── Dockerfile # Flask app container definition
├── docker-compose.yml # Multi-container orchestration
├── docker-entrypoint.sh # Container initialization script
├── init-db.sql # MariaDB initialization
├── .dockerignore # Build optimization
└── .env.example # Configuration template
Deployment & Management
├── deploy.sh # One-command deployment script
├── Makefile # Management commands (make up, make down, etc.)
├── README-DOCKER.md # Quick start guide
├── DOCKER_DEPLOYMENT.md # Complete deployment documentation
└── DOCKER_SOLUTION_SUMMARY.md # This comprehensive summary
Modified Files
py_app/app/db_create_scripts/
└── setup_complete_database.py # Updated to support Docker env vars
🎯 What This Deployment Includes
Services
-
Flask Web Application
- Python 3.10
- Gunicorn WSGI server (production-ready)
- Auto-generated database configuration
- Health checks
- Automatic restart on failure
-
MariaDB 11.3 Database
- Automatic initialization
- User and database creation
- Data persistence (Docker volume)
- Health checks
Features
- ✅ Single-command deployment
- ✅ Automatic database schema setup
- ✅ Superadmin user seeding
- ✅ Data persistence across restarts
- ✅ Container health monitoring
- ✅ Log collection and management
- ✅ Production-ready configuration
- ✅ Easy backup and restore
- ✅ Complete isolation from host system
🚀 How to Deploy
Prerequisites
Install Docker first:
# Ubuntu/Debian
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Log out and back in
Deploy
cd /srv/quality_recticel
./deploy.sh
That's it! Your application will be available at http://localhost:8781
📋 Usage Examples
Basic Operations
# Start services
docker compose up -d
# View logs
docker compose logs -f
# Stop services
docker compose down
# Restart
docker compose restart
# Check status
docker compose ps
Using Makefile (Recommended)
make install # First-time setup
make up # Start services
make down # Stop services
make logs # View logs
make logs-web # View only web logs
make logs-db # View only database logs
make shell # Access app container
make shell-db # Access database console
make backup-db # Backup database
make status # Show service status
make help # Show all commands
Advanced Operations
# Rebuild after code changes
docker compose up -d --build web
# Access application shell
docker compose exec web bash
# Run database commands
docker compose exec db mariadb -u trasabilitate -p trasabilitate
# View resource usage
docker stats recticel-app recticel-db
# Complete reset (removes all data!)
docker compose down -v
🗂️ Data Storage
Persistent Data
- Database: Stored in Docker volume
mariadb_data - Logs: Mounted to
./logsdirectory - Config: Mounted to
./instancedirectory
Backup Database
docker compose exec -T db mariadb-dump -u trasabilitate -pInitial01! trasabilitate > backup.sql
Restore Database
docker compose exec -T db mariadb -u trasabilitate -pInitial01! trasabilitate < backup.sql
🔐 Default Credentials
Application
- URL: http://localhost:8781
- Username:
superadmin - Password:
superadmin123 - ⚠️ Change after first login!
Database
- Host:
localhost:3306(from host) ordb:3306(from containers) - Database:
trasabilitate - User:
trasabilitate - Password:
Initial01! - Root Password: Set in
.envfile
📊 Service Architecture
┌─────────────────────────────────────────────────────┐
│ recticel-network (Docker) │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ recticel-db │ │ recticel-app │ │
│ │ (MariaDB 11.3) │◄───────┤ (Flask/Python) │ │
│ │ │ │ │ │
│ │ - Internal DB │ │ - Gunicorn │ │
│ │ - Health Check │ │ - Health Check │ │
│ │ - Auto Init │ │ - Auto Config │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ │ 3306 (optional) 8781 │ │
└────────────┼──────────────────────────┼────────────┘
│ │
▼ ▼
[mariadb_data] [Host: 8781]
Docker Volume Application Access
🎓 Quick Reference
Environment Variables (.env)
MYSQL_ROOT_PASSWORD=rootpassword # MariaDB root password
DB_PORT=3306 # Database port (external)
APP_PORT=8781 # Application port
INIT_DB=true # Run DB initialization
SEED_DB=true # Seed superadmin user
Important Ports
8781: Flask application (web interface)3306: MariaDB database (optional external access)
Log Locations
- Application logs:
./logs/access.logand./logs/error.log - Container logs:
docker compose logs
🔧 Troubleshooting
Can't connect to application
# Check if services are running
docker compose ps
# Check web logs
docker compose logs web
# Verify port not in use
netstat -tuln | grep 8781
Database connection issues
# Check database health
docker compose exec db healthcheck.sh --connect
# View database logs
docker compose logs db
# Test database connection
docker compose exec web python3 -c "import mariadb; print('OK')"
Port already in use
Edit .env file:
APP_PORT=8782 # Change to available port
DB_PORT=3307 # Change if needed
Start completely fresh
docker compose down -v
rm -rf logs/* instance/external_server.conf
./deploy.sh
📖 Documentation Files
- README-DOCKER.md - Quick start guide (start here!)
- DOCKER_DEPLOYMENT.md - Complete deployment guide
- DOCKER_SOLUTION_SUMMARY.md - Comprehensive overview
- FILES_CREATED.md - This file
✨ Benefits
- No System Dependencies: Only Docker required
- Portable: Deploy on any system with Docker
- Reproducible: Consistent deployments every time
- Isolated: No conflicts with other applications
- Production-Ready: Gunicorn, health checks, proper logging
- Easy Management: Simple commands, one-line deployment
- Persistent: Data survives container restarts
- Scalable: Easy to add more services
🎉 Success!
Your Recticel Quality Application is now containerized and ready for deployment!
Next Steps:
- Install Docker (if not already installed)
- Run
./deploy.sh - Access http://localhost:8781
- Log in with superadmin credentials
- Change default passwords
- Enjoy your containerized application!
For detailed instructions, see README-DOCKER.md or DOCKER_DEPLOYMENT.md.