Skip to content

Conversation

@hk10111
Copy link
Member

@hk10111 hk10111 commented Sep 2, 2025

Change Description

Replaced docker-compose with a utility based on docker official's sdk for python

Testing

Tested with existing tests under test_docker_utils.py
cub and dub do not use the docker_utils so no impact on cub/dub
tested docker utils by using them in base image and running integration tests: https://semaphore.ci.confluent.io/workflows/dd6d367d-c356-4785-af8c-66973ef6d3fb/summary?pipeline_id=791ce31f-24f7-46f4-8503-b220f5b21c61

@hk10111 hk10111 marked this pull request as ready for review September 2, 2025 09:46
Copilot AI review requested due to automatic review settings September 2, 2025 09:46
@hk10111 hk10111 requested a review from a team as a code owner September 2, 2025 09:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the deprecated docker-compose Python library with the official Docker SDK, providing a modern implementation that maintains compatibility with Python 3.10+ while preserving the existing TestCluster interface.

  • Implements a complete replacement for docker-compose functionality using Docker SDK
  • Maintains backward compatibility with existing TestCluster interface
  • Updates all Docker API calls to use the modern Docker SDK patterns

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
confluent/docker_utils/compose_replacement.py New module implementing docker-compose functionality using Docker SDK with classes for config parsing, container management, and project orchestration
confluent/docker_utils/init.py Updates imports and refactors existing functions to use Docker SDK instead of deprecated compose library

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

def is_running(self) -> bool:
"""Check if container is running."""
self.container.reload()
return self.container.status == ContainerStatus.RUNNING.value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be made simpler by converting ContainerStatus to StrEnum. If only use is with .value then it makes sense to use StrEnum.

STATUS = "Status"


# File I/O Constants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment as it is clear from the variable name itself.

# File I/O Constants
FILE_READ_MODE = "r"

# Docker Volume Constants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment as it is clear from the variable name itself.

WORKING_DIR = "working_dir"


class DockerStateKeys(StrEnum):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't seem to go well together, it might be better to use normal constants for this.

from enum import Enum, StrEnum


# Container Status Enums
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment as it is clear from class Name itself.

# In a full implementation, you'd handle building here
raise NotImplementedError("Building images not implemented in this example")

# Command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment

if ComposeConfigKeys.COMMAND in service_config:
config[ComposeConfigKeys.COMMAND] = service_config[ComposeConfigKeys.COMMAND]

# Environment variables
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment

else:
config[ComposeConfigKeys.ENVIRONMENT] = env

# Ports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment

ports[str(port_mapping)] = None
config[ComposeConfigKeys.PORTS] = ports

# Volumes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment

volumes[host_path] = {VOLUME_BIND_MODE: container_path, 'mode': VOLUME_READ_WRITE_MODE}
config[ComposeConfigKeys.VOLUMES] = volumes

# Working directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these redundant comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants