Skip to content

Commit 645301b

Browse files
committed
Compose plugin matching docker-compose for Apple Container
Container Compose brings the convenience of docker-compose to Apple Container, enabling you to: - Define multi-container applications in a single YAML file - Manage service dependencies automatically - Start, stop, and manage entire application stacks with simple commands - Use environment variable interpolation for flexible configurations - Support for multiple --file invocations for compose overrides - Compatibility with Docker Compose volume syntax - Support for --rm flag to compose - Support for --pull and --wait
1 parent ff85a48 commit 645301b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+9682
-129
lines changed

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,22 @@ include Protobuf.Makefile
4646
.PHONY: all
4747
all: container
4848
all: init-block
49+
all: plugins
4950

5051
.PHONY: build
5152
build:
5253
@echo Building container binaries...
5354
@$(SWIFT) --version
5455
@$(SWIFT) build -c $(BUILD_CONFIGURATION)
5556

57+
.PHONY: plugins
58+
plugins: plugin-compose
59+
60+
.PHONY: plugin-compose
61+
plugin-compose:
62+
@echo Building container-compose plugin...
63+
@cd Plugins/container-compose && $(SWIFT) build -c $(BUILD_CONFIGURATION) --product compose
64+
5665
.PHONY: container
5766
# Install binaries under project directory
5867
container: build
@@ -85,6 +94,7 @@ $(STAGING_DIR):
8594
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/container-runtime-linux/bin)"
8695
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/container-network-vmnet/bin)"
8796
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin)"
97+
@mkdir -p "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin)"
8898

8999
@install "$(BUILD_BIN_DIR)/container" "$(join $(STAGING_DIR), bin/container)"
90100
@install "$(BUILD_BIN_DIR)/container-apiserver" "$(join $(STAGING_DIR), bin/container-apiserver)"
@@ -94,6 +104,10 @@ $(STAGING_DIR):
94104
@install config/container-network-vmnet-config.json "$(join $(STAGING_DIR), libexec/container/plugins/container-network-vmnet/config.json)"
95105
@install "$(BUILD_BIN_DIR)/container-core-images" "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin/container-core-images)"
96106
@install config/container-core-images-config.json "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/config.json)"
107+
@if [ -f "Plugins/container-compose/.build/$(BUILD_CONFIGURATION)/compose" ]; then \
108+
install "Plugins/container-compose/.build/$(BUILD_CONFIGURATION)/compose" "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin/compose)"; \
109+
install "Plugins/container-compose/config.json" "$(join $(STAGING_DIR), libexec/container/plugins/compose/config.json)"; \
110+
fi
97111

98112
@echo Install uninstaller script
99113
@install scripts/uninstall-container.sh "$(join $(STAGING_DIR), bin/uninstall-container.sh)"
@@ -106,8 +120,10 @@ installer-pkg: $(STAGING_DIR)
106120
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin/container-core-images)"
107121
@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)"
108122
@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)"
123+
@if [ -f "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin/compose)" ]; then \
124+
codesign $(CODESIGN_OPTS) --prefix=com.apple.container. "$(join $(STAGING_DIR), libexec/container/plugins/compose/bin/compose)"; \
125+
fi
109126

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

@@ -204,3 +220,4 @@ clean:
204220
@rm -rf bin/ libexec/
205221
@rm -rf _site _serve
206222
@$(SWIFT) package clean
223+
@cd Plugins/container-compose && $(SWIFT) package clean 2>/dev/null || true

Plugins/container-compose/BUILD.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Building and Testing Container Compose Plugin
2+
3+
## Prerequisites
4+
5+
- macOS 15 or later
6+
- Swift 6.2 or later
7+
- Main container project dependencies
8+
9+
## Building
10+
11+
### From the main project root:
12+
13+
```bash
14+
# Build everything including the plugin
15+
make all
16+
17+
# Build only the compose plugin
18+
make plugin-compose
19+
20+
# Clean build
21+
make clean
22+
```
23+
24+
### From the plugin directory:
25+
26+
```bash
27+
cd Plugins/container-compose
28+
29+
# Build in debug mode
30+
swift build
31+
32+
# Build in release mode
33+
swift build -c release
34+
35+
# Run the plugin directly
36+
.build/debug/compose --help
37+
```
38+
39+
## Testing
40+
41+
### Run tests from plugin directory:
42+
43+
```bash
44+
cd Plugins/container-compose
45+
46+
# Run all tests
47+
swift test
48+
49+
# Run specific test
50+
swift test --filter ComposeParserTests
51+
52+
# Run with verbose output
53+
swift test --verbose
54+
```
55+
56+
### Manual testing:
57+
58+
1. Build the plugin:
59+
```bash
60+
swift build
61+
```
62+
63+
2. Test basic functionality:
64+
```bash
65+
# Validate a compose file
66+
.build/debug/compose validate -f test-compose.yml
67+
68+
# Show help
69+
.build/debug/compose --help
70+
.build/debug/compose up --help
71+
```
72+
73+
## Installation
74+
75+
### Via main project install:
76+
77+
```bash
78+
# From main project root
79+
make install
80+
```
81+
82+
This installs the plugin to: `/usr/local/libexec/container/plugins/compose/`
83+
84+
### Manual installation:
85+
86+
```bash
87+
# Build in release mode
88+
cd Plugins/container-compose
89+
swift build -c release
90+
91+
# Copy to plugin directory
92+
sudo mkdir -p /usr/local/libexec/container/plugins/compose/bin
93+
sudo cp .build/release/compose /usr/local/libexec/container/plugins/compose/bin/
94+
sudo cp config.json /usr/local/libexec/container/plugins/compose/
95+
```
96+
97+
## Integration Testing
98+
99+
After installation, test the plugin integration:
100+
101+
```bash
102+
# Should work through main container CLI
103+
container compose --help
104+
container compose up --help
105+
106+
# Create a test compose file
107+
cat > test-compose.yml << 'EOF'
108+
version: '3'
109+
services:
110+
web:
111+
image: nginx:alpine
112+
ports:
113+
- "8080:80"
114+
EOF
115+
116+
# Test compose commands
117+
container compose validate -f test-compose.yml
118+
container compose up -d -f test-compose.yml
119+
container compose ps -f test-compose.yml
120+
container compose down -f test-compose.yml
121+
```
122+
123+
## Troubleshooting
124+
125+
### Build Errors
126+
127+
1. **Missing dependencies**: Ensure the main container project is built first
128+
```bash
129+
cd ../..
130+
swift build
131+
```
132+
133+
2. **Swift version**: Check Swift version
134+
```bash
135+
swift --version
136+
```
137+
138+
3. **Clean build**: Try a clean build
139+
```bash
140+
swift package clean
141+
swift build
142+
```
143+
144+
### Runtime Errors
145+
146+
1. **Plugin not found**: Check installation path
147+
```bash
148+
ls -la /usr/local/libexec/container/plugins/compose/
149+
```
150+
151+
2. **Permission issues**: Ensure proper permissions
152+
```bash
153+
sudo chmod +x /usr/local/libexec/container/plugins/compose/bin/compose
154+
```
155+
156+
3. **Debug output**: Enable debug logging
157+
```bash
158+
container compose --debug up
159+
```
160+
161+
## Development Workflow
162+
163+
1. Make changes to the plugin code
164+
2. Build and test locally:
165+
```bash
166+
swift build && swift test
167+
```
168+
3. Test integration:
169+
```bash
170+
make -C ../.. plugin-compose
171+
sudo make -C ../.. install
172+
container compose --help
173+
```
174+
4. Submit changes via PR
175+
176+
## Notes
177+
178+
- The plugin uses a stub for ProgressBar to avoid dependencies on internal APIs
179+
- All compose functionality is self-contained in the plugin
180+
- The plugin can be developed and tested independently of the main project

0 commit comments

Comments
 (0)