{"id":26452006,"url":"https://github.com/abrarkivande/docker-project","last_synced_at":"2026-04-10T15:03:02.204Z","repository":{"id":282918543,"uuid":"950089806","full_name":"AbrarKivande/Docker-Project","owner":"AbrarKivande","description":"Project to learn all docker tools","archived":false,"fork":false,"pushed_at":"2025-03-17T16:09:05.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T18:38:55.466Z","etag":null,"topics":["docker","docker-compose","docker-compose-watch","docker-scout","redis","redis-cache","testcontainers"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/AbrarKivande.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}},"created_at":"2025-03-17T16:03:43.000Z","updated_at":"2025-03-17T16:18:36.000Z","dependencies_parsed_at":"2025-03-17T17:26:52.021Z","dependency_job_id":null,"html_url":"https://github.com/AbrarKivande/Docker-Project","commit_stats":null,"previous_names":["abrarkivande/docker-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AbrarKivande/Docker-Project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbrarKivande%2FDocker-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbrarKivande%2FDocker-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbrarKivande%2FDocker-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbrarKivande%2FDocker-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AbrarKivande","download_url":"https://codeload.github.com/AbrarKivande/Docker-Project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbrarKivande%2FDocker-Project/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274822737,"owners_count":25356575,"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-12T02:00:09.324Z","response_time":60,"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":["docker","docker-compose","docker-compose-watch","docker-scout","redis","redis-cache","testcontainers"],"created_at":"2025-03-18T17:25:47.977Z","updated_at":"2025-12-30T21:24:38.925Z","avatar_url":"https://github.com/AbrarKivande.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-project\n# Docker Productivity Toolkit - README\n\n## 🚀 Overview\nThis project demonstrates how to efficiently use **Docker** to boost productivity when developing, testing, and deploying a **Flask application with Redis**. It showcases various **Docker tools** like:\n\n- **Docker Desktop** (GUI for managing containers)\n- **Docker Compose** (Multi-container orchestration)\n- **Docker Compose Watch** (Live code reloading)\n- **Docker Scout** (Security scanning)\n- **Docker Build Cloud** (Faster builds)\n- **Testcontainers** (Automated testing in isolated environments)\n\n## 📌 Prerequisites\n- Install **[Docker Desktop](https://www.docker.com/products/docker-desktop/)**\n- Install **Python 3.9+**\n- Install **Redis** (Optional, since it will run inside a container)\n- Install **pytest** (for running automated tests)\n\n## 📂 Project Structure\n```\n.\n├── app.py                  # Flask application\n|__ templates               # html file\n├── Dockerfile              # Docker instructions to build image\n├── docker-compose.yml      # Multi-container setup\n├── .dockerignore           # Ignore unnecessary files\n├── requirements.txt        # Python dependencies\n├── test_app.py             # Testcases using Testcontainers\n└── README.md               # Documentation\n```\n\n---\n\n## ⚙️ Step 1: Run the Application Locally\n\n```bash\ngit clone https://github.com/N4si/docker-project.git\ncd docker-project\npip3 install -r requirements.txt\npython3 app.py  # Run Flask app on localhost:5001\n```\n\nCheck the application at **http://localhost:5001**.\n\nTest Redis connection:\n```bash\nredis-cli\nKEYS *\nLRANGE metrics 0 -1\n```\n\n---\n\n## 🐳 Step 2: Containerize with Docker\n\n### 1️⃣ Create a `Dockerfile`\n```dockerfile\n# Use the official Python image\nFROM python:3.9\n\n# Set working directory\nWORKDIR /app\n\n# Copy files\nCOPY . .\n\n# Install dependencies\nRUN pip install --no-cache-dir flask psutil redis\n\n# Expose the port\nEXPOSE 5001\n\n# Run the application\nCMD [\"flask\", \"run\", \"--host=0.0.0.0\", \"--port=5001\", \"--debug\"]\n```\n\n### 2️⃣ Build \u0026 Run the Docker Container\n```bash\ndocker build -t flask-monitor .\ndocker run -p 5001:5001 flask-monitor\n```\n\n---\n\n## 🛠️ Step 3: Use Docker Compose for Multi-Container Setup\n\n### 1️⃣ Create `docker-compose.yml`\n```yaml\n\nservices:\n  web:\n    build: .\n    ports:\n      - \"5001:5001\"\n    environment:\n      - REDIS_HOST=redis\n      - REDIS_PORT=6379\n      - FLASK_APP=app.py\n      - FLASK_ENV=development\n      - FLASK_RUN_HOST=0.0.0.0\n      - FLASK_RUN_PORT=5001\n    depends_on:\n      - redis\n    develop:\n      watch:\n        - action: sync\n          path: .\n          target: /app\n    command: flask run\n\n  redis:\n    image: \"redis:latest\"\n    ports:\n      - \"6379:6379\"\n```\n\n### 2️⃣ Run the Services\n```bash\ndocker compose up -d\n```\n\n### 3️⃣ Stop \u0026 Remove Containers\n```bash\ndocker compose down\n```\n\n---\n\n## 🔄 Step 4: Enable Live Code Reloading with Docker Compose Watch\n```bash\ndocker compose watch\n```\n\nThis will sync code changes automatically without rebuilding the container!\n\n---\n\n## 🔎 Step 5: Scan for Security Vulnerabilities with Docker Scout\n```bash\ndocker scout quickview flask-monitor\ndocker scout cves flask-monitor\n```\n\nUse `docker scout` to get security insights and remediation steps!\n\n---\n\n## 🚀 Step 6: Optimize Build Performance with Docker Build Cloud\n```bash\ndocker buildx version\ndocker buildx create --name mybuilder --use\ndocker buildx bake --progress=plain\n```\n\nFaster builds by caching and running parallel builds.\n\n---\n\n## 🧪 Step 7: Automate Testing with Testcontainers\n\n### 1️⃣ Install Testcontainers\n```bash\npip3 install pytest testcontainers\n```\n\n### 2️⃣ Create `test_app.py`\n```python\nimport pytest\nimport redis\nimport os\nfrom testcontainers.redis import RedisContainer\nfrom app import app\n\n@pytest.fixture(scope=\"module\")\ndef redis_container():\n    with RedisContainer() as redis_container:\n        redis_host = redis_container.get_container_host_ip()\n        redis_port = redis_container.get_exposed_port(6379)\n        os.environ[\"REDIS_HOST\"] = redis_host\n        os.environ[\"REDIS_PORT\"] = str(redis_port)\n        yield redis_host, redis_port\n\n@pytest.fixture\ndef client():\n    app.config[\"TESTING\"] = True\n    with app.test_client() as client:\n        yield client\n\ndef test_redis_connection(redis_container):\n    redis_host, redis_port = redis_container\n    r = redis.Redis(host=redis_host, port=int(redis_port), decode_responses=True)\n    r.set(\"test_key\", \"Hello, Redis!\")\n    assert r.get(\"test_key\") == \"Hello, Redis!\"\n\ndef test_metrics_endpoint(client):\n    response = client.get(\"/metrics\")\n    assert response.status_code == 200\n    data = response.get_json()\n    assert \"cpu\" in data\n    assert \"memory\" in data\n    assert \"disk\" in data\n```\n\n### 3️⃣ Run Tests\n```bash\npython3 -m pytest test_app.py\n```\n\n---\n\n## 🎯 Summary: Key Commands\n| Feature                | Command |\n|------------------------|---------|\n| **Build Image**        | `docker build -t flask-monitor .` |\n| **Run Container**      | `docker run -p 5001:5001 flask-monitor` |\n| **Start Services**     | `docker compose up -d` |\n| **Stop Services**      | `docker compose down` |\n| **Live Reload**        | `docker compose watch` |\n| **Security Scan**      | `docker scout quickview flask-monitor` |\n| **Faster Build**       | `docker buildx bake --progress=plain` |\n| **Run Tests**          | `pytest test_app.py` |\n\n---\n\n## 🏆 Conclusion\n\nBy using these **Docker tools**, you can:\n- **Develop faster** with Docker Compose Watch 🔄\n- **Ensure security** with Docker Scout 🔍\n- **Optimize builds** using Docker Build Cloud 🚀\n- **Automate testing** with Testcontainers ✅\n\n🚀 Now, you're ready to **boost your productivity** with Docker!\n\n---\n\n💡 **Feel free to contribute \u0026 star ⭐ the repo!**\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrarkivande%2Fdocker-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabrarkivande%2Fdocker-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrarkivande%2Fdocker-project/lists"}