Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ include Protobuf.Makefile
.PHONY: all
all: container
all: init-block
all: plugins

.PHONY: build
build:
@echo Building container binaries...
@$(SWIFT) --version
@$(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION)

.PHONY: plugins
plugins: plugin-compose

.PHONY: plugin-compose
plugin-compose:
@echo Building container-compose plugin...
@cd Plugins/container-compose && $(SWIFT) build -c $(BUILD_CONFIGURATION) --product compose

.PHONY: container
# Install binaries under project directory
container: build
Expand Down Expand Up @@ -87,6 +96,7 @@ $(STAGING_DIR):
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/container-runtime-linux/bin)"
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/container-network-vmnet/bin)"
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin)"
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin)"

@install "$(BUILD_BIN_DIR)/container" "$(join $(STAGING_DIR), bin/container)"
@install "$(BUILD_BIN_DIR)/container-apiserver" "$(join $(STAGING_DIR), bin/container-apiserver)"
Expand All @@ -96,6 +106,10 @@ $(STAGING_DIR):
@install config/container-network-vmnet-config.json "$(join $(STAGING_DIR), libexec/container/plugins/container-network-vmnet/config.json)"
@install "$(BUILD_BIN_DIR)/container-core-images" "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin/container-core-images)"
@install config/container-core-images-config.json "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/config.json)"
@if [ -f "Plugins/container-compose/.build/$(BUILD_CONFIGURATION)/compose" ]; then \
install "Plugins/container-compose/.build/$(BUILD_CONFIGURATION)/compose" "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin/compose)"; \
install "Plugins/container-compose/config.json" "$(join $(STAGING_DIR), libexec/container/plugins/compose/config.json)"; \
fi

@echo Install uninstaller script
@install scripts/uninstall-container.sh "$(join $(STAGING_DIR), bin/uninstall-container.sh)"
Expand All @@ -108,8 +122,10 @@ installer-pkg: $(STAGING_DIR)
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin/container-core-images)"
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. --entitlements=signing/container-runtime-linux.entitlements "$(join $(STAGING_DIR), libexec/container/plugins/container-runtime-linux/bin/container-runtime-linux)"
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. --entitlements=signing/container-network-vmnet.entitlements "$(join $(STAGING_DIR), libexec/container/plugins/container-network-vmnet/bin/container-network-vmnet)"
@if [ -f "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin/compose)" ]; then \
codesign $(CODESIGN_OPTS) --prefix=com.apple.container. "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin/compose)"; \
fi

@echo Creating application installer
@pkgbuild --root "$(STAGING_DIR)" --identifier com.apple.container-installer --install-location /usr/local --version ${RELEASE_VERSION} $(PKG_PATH)
@rm -rf "$(STAGING_DIR)"

Expand Down Expand Up @@ -207,3 +223,4 @@ clean:
@rm -rf bin/ libexec/
@rm -rf _site _serve
@$(SWIFT) package clean
@cd Plugins/container-compose && $(SWIFT) package clean 2>/dev/null || true
180 changes: 180 additions & 0 deletions Plugins/container-compose/BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Building and Testing Container Compose Plugin

## Prerequisites

- macOS 15 or later
- Swift 6.2 or later
- Main container project dependencies

## Building

### From the main project root:

```bash
# Build everything including the plugin
make all

# Build only the compose plugin
make plugin-compose

# Clean build
make clean
```

### From the plugin directory:

```bash
cd Plugins/container-compose

# Build in debug mode
swift build

# Build in release mode
swift build -c release

# Run the plugin directly
.build/debug/compose --help
```

## Testing

### Run tests from plugin directory:

```bash
cd Plugins/container-compose

# Run all tests
swift test

# Run specific test
swift test --filter ComposeParserTests

# Run with verbose output
swift test --verbose
```

### Manual testing:

1. Build the plugin:
```bash
swift build
```

2. Test basic functionality:
```bash
# Validate a compose file
.build/debug/compose validate -f test-compose.yml

# Show help
.build/debug/compose --help
.build/debug/compose up --help
```

## Installation

### Via main project install:

```bash
# From main project root
make install
```

This installs the plugin to: `/usr/local/libexec/container/plugins/compose/`

### Manual installation:

```bash
# Build in release mode
cd Plugins/container-compose
swift build -c release

# Copy to plugin directory
sudo mkdir -p /usr/local/libexec/container/plugins/compose/bin
sudo cp .build/release/compose /usr/local/libexec/container/plugins/compose/bin/
sudo cp config.json /usr/local/libexec/container/plugins/compose/
```

## Integration Testing

After installation, test the plugin integration:

```bash
# Should work through main container CLI
container compose --help
container compose up --help

# Create a test compose file
cat > test-compose.yml << 'EOF'
version: '3'
services:
web:
image: nginx:alpine
ports:
- "8080:80"
EOF

# Test compose commands
container compose validate -f test-compose.yml
container compose up -d -f test-compose.yml
container compose ps -f test-compose.yml
container compose down -f test-compose.yml
```

## Troubleshooting

### Build Errors

1. **Missing dependencies**: Ensure the main container project is built first
```bash
cd ../..
swift build
```

2. **Swift version**: Check Swift version
```bash
swift --version
```

3. **Clean build**: Try a clean build
```bash
swift package clean
swift build
```

### Runtime Errors

1. **Plugin not found**: Check installation path
```bash
ls -la /usr/local/libexec/container/plugins/compose/
```

2. **Permission issues**: Ensure proper permissions
```bash
sudo chmod +x /usr/local/libexec/container/plugins/compose/bin/compose
```

3. **Debug output**: Enable debug logging
```bash
container compose --debug up
```

## Development Workflow

1. Make changes to the plugin code
2. Build and test locally:
```bash
swift build && swift test
```
3. Test integration:
```bash
make -C ../.. plugin-compose
sudo make -C ../.. install
container compose --help
```
4. Submit changes via PR

## Notes

- The plugin uses a stub for ProgressBar to avoid dependencies on internal APIs
- All compose functionality is self-contained in the plugin
- The plugin can be developed and tested independently of the main project
Loading