# A Smooth Development Workflow — Docker Compose

Source: https://www.skillbyai.com/en/docker-compose/p-dev

> Fast feedback loops.

## watch, logs, exec, run

For development: bind-mount source code or use **Compose Watch** (`develop.watch` with `docker compose watch`) to sync files and rebuild on changes; follow logs per service; open shells with `exec`; run tests and migrations as one-off `run --rm` commands; and seed data with scripts. Make the first-time setup a single command (copy .env.example, create secrets, `up -d`) and document it.

## Use Compose well

Smooth development workflows, knowing when to move beyond Compose, and a review checklist.

![Three ideas: development workflow, Compose in production, checklist.](assets/figures/docker-compose/section-8-map.svg) — Figure 8.1 — Workflow, production and checklist.

## Compose Watch configuration (sketch)

File sync and rebuild rules for the API; check the Compose docs for your version. Not run here.

```yaml
services:
  api:
    build: ./api
    develop:
      watch:
        - action: sync           # copy changed source files into the container
          path: ./api/src
          target: /app/src
        - action: rebuild        # rebuild the image when dependencies change
          path: ./api/package.json
```

## One command to start

A make up or npm run dev wrapper that prepares .env and secrets and runs Compose removes onboarding friction.

**Quiz:** What is docker compose run --rm useful for?

- [x] One-off tasks like migrations or tests in a temporary container
- [ ] Deleting volumes
- [ ] Publishing ports permanently
- [ ] Building the Compose binary

*Answer:* One-off tasks like migrations or tests in a temporary container. Run and clean up.
