Run Docker Compose Before Services
Use this recipe when part of your local stack is managed by Docker Compose, but your app processes still run directly on the host.
FlowLayer has no Docker-specific orchestration logic. It runs Docker commands like any other process command.
Pattern: oneshot bootstrap service
Create a kind: "oneshot" service that runs docker compose up -d, then make app services depend on it.
{
"services": {
"compose-up": {
"kind": "oneshot",
"cmd": ["docker", "compose", "up", "-d"],
"stopCmd": ["docker", "compose", "down"]
},
"api": {
"cmd": ["pnpm", "--dir", "services/api", "dev"],
"dependsOn": ["compose-up"],
"ready": {
"type": "http",
"url": "http://127.0.0.1:3000/health"
}
},
"worker": {
"cmd": ["pnpm", "--dir", "services/worker", "dev"],
"dependsOn": ["compose-up"]
}
}
}
What happens at runtime
compose-upstarts first and must exit with code 0.apiandworkerare allowed to start after that dependency succeeds.- On graceful shutdown,
stopCmdcan run even ifcompose-upalready exited.
Limits and precautions
docker compose up -dfinishing does not guarantee every container is app-ready.- Add readiness checks on your host services (
httportcp) so dependents do not race. stopCmdis skipped in forced shutdown mode (second interrupt).- Keep Docker commands explicit and local-dev scoped.
Suggested ops flow
- Run
flowlayer-server -c ./flowlayer.jsonc. - Confirm
compose-upexited successfully. - Watch
apireadiness before opening the frontend. - Use graceful stop to ensure
docker compose downis executed.
For additional readiness tuning, see Add Readiness Checks.