|
2 | 2 |
|
3 | 3 | Instantly scaffold a containerised local development environment for any service and database — with a single command. |
4 | 4 |
|
5 | | -Two modes: |
| 5 | +Two modes — both produce a stack that comes up with a single `docker-compose up --build`: |
6 | 6 |
|
7 | | -- **New service** — generates a complete runnable service + `docker-compose.yml` from scratch. |
| 7 | +- **New service** — generates a complete runnable service + `Dockerfile.dev` + `docker-compose.yml` from scratch. Hot-reload enabled. |
8 | 8 | - **Existing service** — wraps your existing code with a `Dockerfile.dev` + `docker-compose.yml`. Hot-reload is enabled; source changes are picked up automatically inside the container. |
9 | 9 |
|
10 | 10 | Optional **database migrations** — pass `--migration <tool>` (Flyway, Liquibase, migrate-mongo, golang-migrate) to scaffold an example migration plus a one-shot `migrate:` service that runs on demand via `docker-compose run --rm migrate`. |
@@ -45,35 +45,43 @@ irm https://raw.githubusercontent.com/krishgok/localdevstack/main/scripts/instal |
45 | 45 |
|
46 | 46 | ## Usage: Scaffold a new service |
47 | 47 |
|
48 | | -Generates source code + `docker-compose.yml` from scratch. |
| 48 | +Generates source code + `Dockerfile.dev` + `docker-compose.yml` from scratch. Hot-reload is enabled — edit source files and the watcher inside the container recompiles/restarts your service automatically. |
49 | 49 |
|
50 | 50 | **Step 1 — Generate the stack:** |
51 | 51 |
|
52 | 52 | ```bash |
53 | 53 | localdevstack --service go --database postgres --output ./my-project --name my-api |
54 | 54 | ``` |
55 | 55 |
|
56 | | -**Step 2 — Start the database:** |
| 56 | +This produces: |
57 | 57 |
|
58 | | -```bash |
59 | | -cd my-project |
60 | | -docker-compose up -d |
| 58 | +``` |
| 59 | +my-project/ |
| 60 | +├── service/ |
| 61 | +│ ├── <generated source files> |
| 62 | +│ └── Dockerfile.dev ← dev container for your service (hot-reload enabled) |
| 63 | +└── docker-compose.yml ← your service + the database, fully wired |
61 | 64 | ``` |
62 | 65 |
|
63 | | -**Step 3 — Start the generated service:** |
| 66 | +**Step 2 — Start the full local stack:** |
64 | 67 |
|
65 | 68 | ```bash |
66 | | -cd service && go run ./... |
| 69 | +cd my-project |
| 70 | +docker-compose up --build |
67 | 71 | ``` |
68 | 72 |
|
69 | | -**Step 4 — Verify:** |
| 73 | +This builds the dev image on first run and starts both the database and your service. Subsequent `docker-compose up` calls skip the build. |
| 74 | + |
| 75 | +**Step 3 — Verify:** |
70 | 76 |
|
71 | 77 | ```bash |
72 | 78 | curl http://localhost:8080/health |
73 | 79 | # → {"status":"ok"} |
74 | 80 | ``` |
75 | 81 |
|
76 | | -> The service runs directly on your host in this mode. Replace `go run ./...` with the appropriate command for your language (see [Supported service types](#supported-service-types)). |
| 82 | +**Step 4 — Edit, save, and see changes reload automatically:** |
| 83 | + |
| 84 | +Hot-reload works the same way as in [existing-service mode](#step-4--edit-save-and-see-changes-reload-automatically) — edit a source file under `service/`, the watcher inside the container picks it up. Only re-run `docker-compose up --build` if you change `Dockerfile.dev` itself or add/remove dependencies (e.g. `go.mod`, `package.json`, `requirements.txt`). |
77 | 85 |
|
78 | 86 | --- |
79 | 87 |
|
@@ -298,9 +306,8 @@ Pass `--migration <tool>` to scaffold migration files plus a one-shot `migrate:` |
298 | 306 | ```bash |
299 | 307 | localdevstack --service go --database postgres --migration flyway --output ./my-project --name my-api |
300 | 308 | cd my-project |
301 | | -docker-compose up -d # starts postgres only — migrate is skipped (compose profile) |
302 | | -docker-compose run --rm migrate # applies all pending migrations |
303 | | -cd service && go run ./... # start your service |
| 309 | +docker-compose up --build -d # service + db (migrate skipped — compose profile) |
| 310 | +docker-compose run --rm migrate # apply migrations on demand |
304 | 311 | ``` |
305 | 312 |
|
306 | 313 | ### Existing service with migrations |
|
0 commit comments