Stack
Main orchestrator for Docker Compose stacks.
Source code in orche/stack.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
__init__(name=None, path='.', compose_files=None)
Initialize a Docker Compose stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Optional project name (defaults to directory name) |
None
|
path
|
str | Path
|
Project root path (defaults to current directory) |
'.'
|
compose_files
|
list[str] | list[Path] | None
|
List of docker-compose file paths (relative to project path or abs). Files are merged in order (later files override earlier ones). Defaults to ["docker-compose.yml"] if None. Cannot be an empty list. |
None
|
Raises:
| Type | Description |
|---|---|
ConfigError
|
If compose_files is empty or files do not exist |
Source code in orche/stack.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
build(services=None)
Build services in the stack.
If 'services' is not provided, uses the active services from CLI args.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
services
|
list[str] | None
|
Optional list of specific services to build |
None
|
Returns:
| Type | Description |
|---|---|
Stack
|
Self for method chaining |
Source code in orche/stack.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
client()
Get the underlying DockerComposeWrapper instance.
Source code in orche/stack.py
355 356 357 | |
down(services=None, volumes=False)
Stop and remove services in the stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
services
|
list[str] | None
|
Optional list of specific services to stop and remove |
None
|
volumes
|
bool
|
Whether to remove named volumes |
False
|
Returns:
| Type | Description |
|---|---|
Stack
|
Self for method chaining |
Source code in orche/stack.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
on(services)
Return True if at least one of the specified services is active.
This method uses OR logic across the provided service names and checks
membership against the current execution context (self._active_services).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
services
|
str | list[str]
|
A service name or list of service names to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if any of the specified services are active, False otherwise. |
Source code in orche/stack.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
print_services_summary()
Print a Rich panel listing running services and their local URLs.
Source code in orche/stack.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
run(command, services=None)
Execute a command with before/after hooks.
Execution order
- Before-hooks run sequentially. First failure raises
HookErrorand aborts (remaining hooks and handler are skipped). - Main handler runs only if all before-hooks succeeded.
Failures raise
CommandError;KeyboardInterruptpropagates. - After-hooks run sequentially. First failure raises
HookErrorand aborts (remaining after-hooks are skipped).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Command name to execute. |
required |
services
|
list[str] | None
|
List of service names. |
None
|
Raises:
| Type | Description |
|---|---|
CommandError
|
If the command is not registered or the handler fails. |
HookError
|
If a before- or after-hook fails. |
Source code in orche/stack.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
stop(services=None)
Stop services without removing them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
services
|
list[str] | None
|
Optional list of specific services to stop |
None
|
Returns:
| Type | Description |
|---|---|
Stack
|
Self for method chaining |
Source code in orche/stack.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
up(services=None, wait=True)
Start services in the stack.
If 'services' is not provided, uses the active services from CLI args.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
services
|
list[str] | None
|
Optional list of specific services to start |
None
|
wait
|
bool
|
If True, wait for services to be running |
True
|
Returns:
| Type | Description |
|---|---|
Stack
|
Self for method chaining |
Source code in orche/stack.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |