Skip to content

[CI/Build] Optimize Docker Image Size: Remove Test and Example Files from Application Build #615

@ikaadil

Description

@ikaadil

Description

Currently, the Dockerfiles(Dockerfile, Dockerfile.kvaware) copies the entire src/ directory which includes test and example files that are not needed in the production environment. This unnecessarily increases the Docker image size and includes code that should only be present in development environments.

Current Structure in src/:

  • examples/
  • gateway_inference_extension/
  • tests/
  • vllm_router/

Problem

The current Dockerfile includes the following line:

COPY src/ src/

This copies all subdirectories including tests and examples which are not required for the production application. This:

  1. Increases the Docker image size unnecessarily
  2. Includes development/test code in production environments
  3. Deviates from Docker best practices of maintaining minimal production images

Proposed Solution

  1. Modify the Dockerfile to only copy required production code:
COPY src/vllm_router/ src/vllm_router/
COPY src/gateway_inference_extension/ src/gateway_inference_extension/
  1. Consider restructuring the project to separate production code from development resources

Benefits

  • Reduced Docker image size
  • Cleaner production environment
  • Better separation of concerns between production and development code
  • Follows Docker best practices for production images

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions