Skip to content

Optimize Docker image sizes for FL client and server containers #37

@abdulmeLINK

Description

@abdulmeLINK

The current Docker images for FL client and server components are excessively large due to several optimization opportunities:

Current Issues

  1. Large ML Dependencies: Both images include PyTorch (torch==1.13.1) and TorchVision (torchvision==0.14.1), which significantly increase image size
  2. Unnecessary Files: The entire src/ directory is copied including pycache and potentially unused files
  3. No Multi-stage Builds: Single-stage builds include build dependencies in final images
  4. Excessive Networking Tools: Multiple networking utilities installed that may not all be needed
  5. Cache Not Cleaned: pip and apt caches not properly cleaned

Impact

  • Increased storage requirements
  • Slower image pulls and deployments
  • Higher bandwidth usage in GNS3 environments
  • Longer build times

Proposed Solutions

  1. Multi-stage Builds: Use separate build and runtime stages
  2. Selective Dependencies: Only install required ML libraries or use lighter alternatives
  3. Minimal Base Images: Consider alpine-based images or distroless
  4. Clean Copy Operations: Use .dockerignore and exclude unnecessary files
  5. Runtime Optimizations: Use python -m py_compile for bytecode, remove pip cache

Files to Update

  • docker/flopynet_fl_client.Dockerfile
  • docker/flopynet_fl_server.Dockerfile
  • docker/requirements/fl-client-requirements.txt
  • docker/requirements/fl-server-requirements.txt

Acceptance Criteria

  • Reduce image size by at least 50%
  • Maintain all required functionality
  • No breaking changes to container interfaces
  • Document size improvements in build logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfl-clientFederated Learning client issuesfl-serverFederated Learning server issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions