{"id":31385783,"url":"https://github.com/rafeekpro/flask-uwsgi-nginx-certbot-docker","last_synced_at":"2025-09-28T19:00:14.020Z","repository":{"id":86912369,"uuid":"183691892","full_name":"rafeekpro/Flask-uWSGI-Nginx-Certbot-Docker","owner":"rafeekpro","description":"Create  Flask app with uWSGI, Nginx, Certbot for SSL and all this with docker","archived":false,"fork":false,"pushed_at":"2025-09-06T17:20:35.000Z","size":42,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-06T17:33:29.800Z","etag":null,"topics":["certbot","docker","docker-compose","flask","uwsgi","uwsgi-nginx"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafeekpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-04-26T20:44:09.000Z","updated_at":"2025-09-06T15:27:06.000Z","dependencies_parsed_at":"2023-03-03T18:15:16.345Z","dependency_job_id":null,"html_url":"https://github.com/rafeekpro/Flask-uWSGI-Nginx-Certbot-Docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rafeekpro/Flask-uWSGI-Nginx-Certbot-Docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafeekpro%2FFlask-uWSGI-Nginx-Certbot-Docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafeekpro%2FFlask-uWSGI-Nginx-Certbot-Docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafeekpro%2FFlask-uWSGI-Nginx-Certbot-Docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafeekpro%2FFlask-uWSGI-Nginx-Certbot-Docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafeekpro","download_url":"https://codeload.github.com/rafeekpro/Flask-uWSGI-Nginx-Certbot-Docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafeekpro%2FFlask-uWSGI-Nginx-Certbot-Docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277415658,"owners_count":25814154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["certbot","docker","docker-compose","flask","uwsgi","uwsgi-nginx"],"created_at":"2025-09-28T19:00:11.592Z","updated_at":"2025-09-28T19:00:13.961Z","avatar_url":"https://github.com/rafeekpro.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask + uWSGI + Nginx + Certbot Docker Application\n\n[![CI/CD Pipeline](https://github.com/yourusername/yourrepo/actions/workflows/ci.yml/badge.svg)](https://github.com/yourusername/yourrepo/actions/workflows/ci.yml)\n[![Python Version](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nProduction-ready Flask application with uWSGI, Nginx, and Let's Encrypt SSL certificates, all containerized with Docker.\n\n## 🚀 Features\n\n- **Modern Python**: Python 3.12 with type hints\n- **Security First**: Talisman security headers, CORS configuration, SSL/TLS support\n- **Production Ready**: uWSGI application server, Nginx reverse proxy\n- **Automated SSL**: Let's Encrypt certificate management with Certbot\n- **CI/CD Pipeline**: GitHub Actions with testing, linting, and security scanning\n- **Code Quality**: Black, isort, flake8, mypy, pre-commit hooks\n- **Testing**: Comprehensive test suite with pytest and coverage\n- **Monitoring**: Structured logging, health checks, error tracking ready\n- **Docker**: Multi-stage builds, security scanning, optimized images\n\n## 📋 Prerequisites\n\n- Docker \u0026 Docker Compose\n- Python 3.11+ (for local development)\n- Domain name (for SSL certificates)\n\n## 🛠️ Quick Start\n\n### 1. Clone the repository\n```bash\ngit clone https://github.com/yourusername/yourrepo.git\ncd yourrepo\n```\n\n### 2. Setup environment\n```bash\ncp .env.example .env\n# Edit .env with your configuration\n```\n\n### 3. Start with Docker\n```bash\n# Build and start all services\ndocker-compose up --build -d\n\n# View logs\ndocker-compose logs -f\n```\n\n### 4. Setup SSL certificates (Production)\n```bash\n# Edit domain in init-letsencript.sh\nnano init-letsencript.sh\n\n# Run certificate initialization\n./init-letsencript.sh\n```\n\n## 💻 Local Development\n\n### Setup development environment\n```bash\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Install dependencies\npip install -r flask_app/requirements.txt\n\n# Install pre-commit hooks\npre-commit install\n\n# Run the application\ncd flask_app\npython app.py\n```\n\n### Run tests\n```bash\n# Run all tests with coverage\npytest\n\n# Run specific test file\npytest tests/test_app.py\n\n# Run with verbose output\npytest -v\n\n# Generate HTML coverage report\npytest --cov-report=html\n```\n\n### Code formatting and linting\n```bash\n# Format code with Black\nblack flask_app/ tests/\n\n# Sort imports\nisort flask_app/ tests/\n\n# Lint with flake8\nflake8 flask_app/ tests/\n\n# Type checking with mypy\nmypy flask_app/\n\n# Run all checks\npre-commit run --all-files\n```\n\n## 📁 Project Structure\n\n```\n.\n├── flask_app/\n│   ├── app.py                 # Main application\n│   ├── requirements.txt       # Python dependencies\n│   ├── uwsgi.ini             # uWSGI configuration\n│   └── frontend/\n│       ├── __init__.py\n│       ├── routes.py         # Route definitions\n│       └── api/\n│           └── Content.py    # API client\n├── tests/\n│   ├── conftest.py          # Pytest configuration\n│   ├── test_app.py          # Application tests\n│   └── test_content.py      # Content API tests\n├── data/\n│   ├── nginx/\n│   │   └── app.conf         # Nginx configuration\n│   └── certbot/             # SSL certificates\n├── .github/\n│   └── workflows/\n│       └── ci.yml           # CI/CD pipeline\n├── docker-compose.yml       # Docker services\n├── Dockerfile              # Application container\n├── init-letsencript.sh    # SSL setup script\n├── pyproject.toml         # Python project config\n├── .pre-commit-config.yaml # Pre-commit hooks\n└── .env.example           # Environment template\n```\n\n## 🔧 Configuration\n\n### Environment Variables\n\nSee `.env.example` for all available options:\n\n- `FLASK_ENV`: Application environment (production/development)\n- `SECRET_KEY`: Flask secret key for sessions\n- `API_ADDRESS`: External API endpoint\n- `ALLOWED_ORIGINS`: CORS allowed origins\n- `DOMAIN`: Your domain for SSL certificates\n- `EMAIL`: Email for Let's Encrypt notifications\n\n### Docker Services\n\n- **memberxxl_app**: Flask application on uWSGI\n- **nginx**: Reverse proxy and static file server\n- **certbot**: SSL certificate management\n\n## 🚢 Deployment\n\n### Production Checklist\n\n- [ ] Set strong `SECRET_KEY` in `.env`\n- [ ] Configure proper `ALLOWED_ORIGINS`\n- [ ] Update domain in `init-letsencript.sh`\n- [ ] Set `FLASK_ENV=production`\n- [ ] Configure monitoring (Sentry, New Relic, etc.)\n- [ ] Setup backup strategy\n- [ ] Configure firewall rules\n- [ ] Enable automatic certificate renewal\n\n### Docker Hub Deployment\n\n```bash\n# Build and tag image\ndocker build -t yourusername/flask-app:latest .\n\n# Push to registry\ndocker push yourusername/flask-app:latest\n\n# Deploy on server\ndocker-compose pull\ndocker-compose up -d\n```\n\n## 🧪 CI/CD Pipeline\n\nGitHub Actions workflow runs on every push and PR:\n\n1. **Testing**: Multiple Python versions, pytest with coverage\n2. **Code Quality**: Black, isort, flake8, mypy\n3. **Security**: Trivy, Bandit security scanning\n4. **Docker**: Build and push to registry (on master)\n\n## 🔐 Security\n\n- **Dependencies**: Automated vulnerability scanning with Trivy\n- **Code**: Static analysis with Bandit\n- **Headers**: Security headers with Flask-Talisman\n- **HTTPS**: Enforced in production with Let's Encrypt\n- **Docker**: Non-root user, minimal base image\n- **Secrets**: Environment variables, never in code\n\n## 📊 Monitoring\n\n- **Health Check**: `/health` endpoint for monitoring\n- **Logging**: Structured logs with rotation\n- **Metrics**: Ready for Prometheus/Grafana integration\n- **Error Tracking**: Sentry integration ready\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit changes (`git commit -m 'Add amazing feature'`)\n4. Push to branch (`git push origin feature/amazing-feature`)\n5. Open Pull Request\n\n### Development Standards\n\n- Follow PEP 8 and use Black formatter\n- Write tests for new features\n- Update documentation\n- Pass all CI checks\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- [Flask](https://flask.palletsprojects.com/) - Web framework\n- [uWSGI](https://uwsgi-docs.readthedocs.io/) - Application server\n- [Nginx](https://nginx.org/) - Web server\n- [Let's Encrypt](https://letsencrypt.org/) - Free SSL certificates\n- [Docker](https://www.docker.com/) - Containerization\n\n## 📧 Support\n\nFor issues and questions:\n- Open an [issue](https://github.com/yourusername/yourrepo/issues)\n- Email: support@example.com\n\n---\n\nMade with ❤️ using modern Python and DevOps best practices","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafeekpro%2Fflask-uwsgi-nginx-certbot-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafeekpro%2Fflask-uwsgi-nginx-certbot-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafeekpro%2Fflask-uwsgi-nginx-certbot-docker/lists"}