Skip to content

Releases: ddaakk/docker-boot

0.2.0

22 Nov 02:00

Choose a tag to compare

Release Notes

Version 0.2.0 (2024-03-22)

Major Features

1. Container Lifecycle Management Modes

Added flexible container lifecycle management through configurable modes:

docker:
  containers:
    redis:
      lifecycle-mode: START_AND_STOP  # New configuration option
  • START_AND_STOP (Default)

    • Full lifecycle management
    • Container starts with application
    • Automatic cleanup on shutdown
    • Best for development environments
  • START_ONLY

    • Partial lifecycle management
    • Container starts with application
    • Persists after application shutdown
    • Ideal for shared services
  • NONE

    • Manual lifecycle management
    • No automatic start/stop
    • For externally managed containers
    • Perfect for pre-existing services

2. Enhanced Event System

Introduced comprehensive event-based container management:

public class DockerContainerEvent extends ApplicationEvent {
    public enum Action {
        START,   // Create and start container
        STOP,    // Stop running container
        REMOVE   // Remove container
    }
}

Event Publishing Example:

@Service
public class DockerService {
    private final ApplicationEventPublisher eventPublisher;
    
    @Autowired
    public DockerService(ApplicationEventPublisher eventPublisher) {
        this.eventPublisher = eventPublisher;
    }
    
    public void triggerContainerAction(Action action) {
        eventPublisher.publishEvent(new DockerContainerEvent(this, action));
    }
}

Event Handling Example:

@Service
public class ContainerManager extends AbstractDockerContainerManager {
    @EventListener
    public void handleDockerEvent(DockerContainerEvent event) {
        logger.info("Received Docker container event: {}", event.getAction());
        switch (event.getAction()) {
            case START:
                createAndStart();
                break;
            case STOP:
                if (containerId.get() != null) {
                    stop(containerId.get());
                }
                break;
            case REMOVE:
                if (containerId.get() != null) {
                    remove(containerId.get());
                }
                break;
        }
    }
}

Migration Guide

Upgrading to Lifecycle Modes

From previous version:

docker:
  containers:
    redis:
      enabled: true
      container-name: redis

To new version:

docker:
  containers:
    redis:
      enabled: true
      container-name: redis
      lifecycle-mode: START_AND_STOP  # Add this line

Implementing Event Handling

  1. Create event handler:
@EventListener
public void handleDockerEvent(DockerContainerEvent event) {
    // Handle container events
}
  1. Publish events:
eventPublisher.publishEvent(new DockerContainerEvent(this, Action.START));

Breaking Changes

  • Default container behavior now follows START_AND_STOP mode
  • Existing custom container managers need to implement getLifecycleMode()

Bug Fixes

  • Fixed container cleanup on abnormal shutdown
  • Improved event handling thread safety
  • Enhanced error logging for lifecycle transitions

Known Issues

  • Multiple event listeners might cause duplicate actions
  • NONE mode containers still log lifecycle messages

Upcoming Features

  • Container dependency management
  • Enhanced health check support
  • Custom lifecycle mode implementations

Full Changelog: https://github.com/ddaakk/docker-boot/commits/Latest