{"id":29067021,"url":"https://github.com/byteakp/optidock","last_synced_at":"2025-06-27T10:10:12.343Z","repository":{"id":292105496,"uuid":"979826558","full_name":"byteakp/OptiDock","owner":"byteakp","description":"OptiDock  is a CLI tool designed to analyze, optimize, and secure Docker images.","archived":false,"fork":false,"pushed_at":"2025-05-08T06:49:19.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T07:30:56.244Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/byteakp.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}},"created_at":"2025-05-08T06:08:31.000Z","updated_at":"2025-05-08T06:49:22.000Z","dependencies_parsed_at":"2025-05-08T07:41:21.838Z","dependency_job_id":null,"html_url":"https://github.com/byteakp/OptiDock","commit_stats":null,"previous_names":["byteakp/optidock"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/byteakp/OptiDock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteakp%2FOptiDock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteakp%2FOptiDock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteakp%2FOptiDock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteakp%2FOptiDock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byteakp","download_url":"https://codeload.github.com/byteakp/OptiDock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteakp%2FOptiDock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262235802,"owners_count":23279571,"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","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":[],"created_at":"2025-06-27T10:10:11.222Z","updated_at":"2025-06-27T10:10:12.316Z","avatar_url":"https://github.com/byteakp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Container Optimization Tool (COT)\n\nA powerful CLI tool for analyzing and optimizing Docker containers.\n\n![Container Optimization Tool](\u003chttps://media-hosting.imagekit.io/3e7457bec7f64979/Screenshot%20from%202025-05-08%2011-57-07.png?Expires=1841294854\u0026Key-Pair-Id=K2ZIVPTIP2VGHC\u0026Signature=cfdAAlaVZjtmFsI~t6rTS~QiRHZhiILyucOxeI1s3MyuVLhzDEfzOhNBuRftinzOlwSe9GNc3kYkxc2fyXTak1UUN3RpfOyNfxNa8t3RCSf6252ibsns08ZkRCRDOghVVFvDPTVuJu~EMAItOBsXNkzV8X0kmSGiA2uwdDEjccRnPG4kPdk6HJphimIrl9ncBCQ5XmQOoAqvaI59LlBH9MmBoUrKA3grlcP69-rw9vuah7pkoHFi44uz-oVuv-V3QmM4RT3ZLijcOdtRF7VebbzCmPcnBrT34vfnySQKfXJN~NW5w~GVvf8dvcdrirWLFj6jqwHuQx7nZic6ytwPXw__\u003e)\n![Container Optimization Tool](\u003chttps://media-hosting.imagekit.io/722dbf1e88f5463c/Screenshot%20from%202025-05-08%2011-57-19.png?Expires=1841294918\u0026Key-Pair-Id=K2ZIVPTIP2VGHC\u0026Signature=mrOWXvN8OVuthTMUdHgvCzCTG1Em8fDujnnGszCB4V4LgDlfEmUWD8Z4JoaQTBwiA16OFyzFxX1gqwyM9U9jQ20EaYwYDfxM5a3hBOY0IDufYJCGlOnQxRoNn5iEdY-rflufww9UqkjFHBDHivL8iWjTNDP2JUu5XqR-gjWqKuc9qUHPSnpruRZGWpXZqeIjI4NKdWnwcIcS1It1ZeheW5vLwDbH8zGVFdkCqbFNVHCEZitSKdkb0E5zp1~Z04vMQkzjynkf3VK2J~e9JHwL6wKBBHKgi~zo1lWB5gyWe37IQ~eDpeV~be9ZYfc0JnAfbxrygGbgSHYZHmnyTpa69Q__\u003e)\n## Features\n\n- **Image Analysis**: Deep inspection of Docker images to identify optimization opportunities\n- **Multi-Stage Build Suggestions**: Automatically generates multi-stage Dockerfile templates\n- **Security Scanning**: Identifies common vulnerabilities in container images\n- **Dockerfile Optimization**: Analyzes and improves existing Dockerfiles\n- **Cost Estimation**: Calculates potential savings from optimizations\n\n## Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/byteakp/OptiDock.git\ncd container-optimization-tool\n\n# Install requirements\npip install -r requirements.txt\n\n# Install the tool\npip install -e .\n\n# Verify installation\ncontainer-opt --version\n```\n\n## Usage\n\n### Analyze a Docker Image\n\n```bash\n# Analyze an image for all optimization opportunities\ncontainer-opt analyze python:3.9\n\n# Analyze for specific optimization types\ncontainer-opt analyze --type security nginx:latest\ncontainer-opt analyze --type size node:14\ncontainer-opt analyze --type cost postgres:13\n\n# Analyze with an existing Dockerfile\ncontainer-opt analyze --dockerfile ./Dockerfile myapp:latest\n\n# Show only summary information\ncontainer-opt analyze --no-details python:3.9\n```\n\n### Optimize a Dockerfile\n\n```bash\n# Generate an optimized version of a Dockerfile\ncontainer-opt optimize-dockerfile ./Dockerfile\n\n# Save to a custom location\ncontainer-opt optimize-dockerfile ./Dockerfile --output ./Dockerfile.optimized\n```\n\n## Sample Output\n\n```\n================================================================================\n🐳 CONTAINER OPTIMIZATION REPORT FOR python:3.9\n================================================================================\n📊 Image Size: 943.57 MB\n📅 Report Generated: 2025-05-08 10:15:32\n--------------------------------------------------------------------------------\n\n🔒 SECURITY VULNERABILITIES: 3\n--------------------------------------------------------------------------------\nCRITICAL: 0\nHIGH: 1\nMEDIUM: 2\nLOW: 0\n\nDetails:\n  1. [HIGH] pyyaml: Code Execution vulnerability in PyYAML\n     Fix: Update to version 5.4.0\n     CVE: CVE-2020-14343\n\n  2. [MEDIUM] urllib3: Improper certificate validation\n     Fix: Update to version 1.26.5\n     CVE: CVE-2021-33503\n\n  3. [MEDIUM] libc6: Memory corruption vulnerability\n     Fix: Update to version 2.31-13+deb11u4\n     CVE: CVE-2021-35942\n\n\n📦 SIZE OPTIMIZATION OPPORTUNITIES: 4\n--------------------------------------------------------------------------------\nTotal Potential Size Reduction: ~195.0 MB\n\nDetails:\n  1. APT_CACHE: Package manager cache not cleaned after installation\n     Potential Savings: 20-100MB\n     Suggestion: Add 'apt-get clean \u0026\u0026 rm -rf /var/lib/apt/lists/*' after installations\n\n  2. PIP_CACHE: Python pip cache not removed\n     Potential Savings: 10-50MB\n     Suggestion: Use '--no-cache-dir' with pip or remove cache directory\n\n  3. TEMP_FILES: Temporary files and documentation may be included\n     Potential Savings: 5-50MB\n     Suggestion: Remove temporary files, documentation, and test files\n\n  4. MULTI_STAGE: Python web application could benefit from multi-stage build\n     Potential Savings: 100-200MB\n     Suggestion: Use multi-stage build to separate build and runtime dependencies\n\n\n📄 DOCKERFILE OPTIMIZATION SUGGESTIONS: 3\n--------------------------------------------------------------------------------\n\nDetails:\n  1. Line 1: FROM python:3.9\n     Suggestion: FROM python:3.10-slim\n     Reason: Consider using a smaller base image like python:3.10-slim\n     Potential Savings: 50-200MB\n\n  2. Line 5: RUN pip install -r requirements.txt\n     Suggestion: RUN pip install --no-cache-dir -r requirements.txt\n     Reason: Use --no-cache-dir with pip to avoid storing package cache\n     Potential Savings: 10-50MB\n\n  3. Line 8: COPY . /app\n     Suggestion: COPY . /app\n     Reason: Consider using a .dockerignore file to exclude unnecessary files (node_modules, .git, etc.)\n     Potential Savings: Variable, potentially 10-500MB\n\n\n🏗️ MULTI-STAGE BUILD RECOMMENDATION\n--------------------------------------------------------------------------------\nA multi-stage build could significantly reduce image size.\n\nSuggested Dockerfile:\n# Build stage\nFROM python:3.10-slim AS builder\n\nWORKDIR /app\n\n# Install build dependencies\nRUN apt-get update \u0026\u0026 apt-get install -y --no-install-recommends \\\n    build-essential \\\n    \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\n# Install Python dependencies\nCOPY requirements.txt .\nRUN pip install --no-cache-dir -r requirements.txt\n\n# Copy application code\nCOPY . .\n\n# Runtime stage\nFROM python:3.10-slim\n\nWORKDIR /app\n\n# Copy only necessary files from builder\nCOPY --from=builder /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/\nCOPY --from=builder /app/ /app/\n\n# Set Python path and run command\nENV PYTHONPATH=/app\n\nCMD [\"python\", \"app.py\"]\n\n\n💰 COST SAVINGS ESTIMATE\n--------------------------------------------------------------------------------\n\nEstimated Monthly Cost Savings (based on 10 containers):\n- Storage: $0.02/month\n- Transfer: $0.29/month\n- Total: $0.31/month\n\nAdditional Benefits:\n- Build time reduction: ~9 seconds per build\n- Reduced deployment time: ~7 seconds per deployment\n- Lower resource usage during container startup\n\n\n🚀 SUMMARY RECOMMENDATIONS\n--------------------------------------------------------------------------------\n1. Fix 1 critical/high security vulnerabilities\n2. Implement multi-stage build to significantly reduce image size\n3. Clean package manager caches after installation\n\n================================================================================\n```\n\n## Advanced Usage\n\n### Configuration File\n\nYou can create a `cot.yaml` configuration file in your project to set defaults:\n\n```yaml\ndefault_optimization_type: size\nreport_detail_level: high\ncost_calculator:\n  container_count: 20\n  monthly_deployments: 15\n```\n\n### Integration with CI/CD\n\nAdd to your GitHub Actions workflow:\n\n```yaml\n- name: Analyze Docker image\n  run: |\n    pip install container-optimization-tool\n    container-opt analyze --type all myapp:latest --dockerfile ./Dockerfile\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyteakp%2Foptidock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyteakp%2Foptidock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyteakp%2Foptidock/lists"}