local-development-gateway 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -28
  3. data/docker-compose.yml +19 -20
  4. data/docs/README.md +16 -0
  5. data/docs/architecture/gateway-lifecycle.md +39 -0
  6. data/docs/guides/consumer-developer-examples.md +369 -0
  7. data/docs/guides/docker-first-migration.md +180 -0
  8. data/docs/guides/docker-installation.md +84 -0
  9. data/docs/requirements/effective-gateway.md +37 -0
  10. data/examples/shared-databases/README.md +145 -0
  11. data/examples/shared-databases/app/.omp-verifier.json +10 -0
  12. data/examples/shared-databases/app/.oxlintrc.json +3 -0
  13. data/examples/shared-databases/app/Dockerfile +12 -0
  14. data/examples/shared-databases/app/app.mjs +91 -0
  15. data/examples/shared-databases/app/app.test.mjs +67 -0
  16. data/examples/shared-databases/app/database.mjs +31 -0
  17. data/examples/shared-databases/app/migrations/001_notes.cjs +10 -0
  18. data/examples/shared-databases/app/package-lock.json +1705 -0
  19. data/examples/shared-databases/app/package.json +18 -0
  20. data/examples/shared-databases/bin/dev +63 -0
  21. data/examples/shared-databases/bin/provision +24 -0
  22. data/examples/shared-databases/compose.yml +73 -0
  23. data/examples/shared-databases/consumer.yml +64 -0
  24. data/examples/shared-databases/gateway.yml +24 -0
  25. data/examples/shared-databases/provisioning/checkout.sh +12 -0
  26. data/examples/shared-databases/provisioning/postgres/database.sql +16 -0
  27. data/examples/shared-databases/provisioning/postgres/provision.sh +10 -0
  28. data/examples/shared-databases/provisioning/postgres/role.sql +11 -0
  29. data/examples/shared-databases/provisioning/sqlserver/database.sql +34 -0
  30. data/examples/shared-databases/provisioning/sqlserver/login.sql +18 -0
  31. data/examples/shared-databases/provisioning/sqlserver/provision.sh +10 -0
  32. data/lib/local_development_gateway/lifecycle.rb +133 -0
  33. data/lib/local_development_gateway/version.rb +1 -1
  34. data/lib/local_development_gateway.rb +150 -27
  35. metadata +31 -3
  36. data/config/traefik.yml +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 934a925eb1f2528d82b9b49be2f2f36b25b6b03faa48e93d981cdefef10f9ccc
4
- data.tar.gz: 35a20441b26783881c226c076fadf0bb15a13f3eb7630d36d28890d2a0f66beb
3
+ metadata.gz: a6be66d9ba73f3dfab0b7c64971a94c9b83270b48b519909df1f026f325dbb01
4
+ data.tar.gz: d423a29d185b4cf383eed5ebd40b62d29277f96f630b15c5b18fa1927a420bdd
5
5
  SHA512:
6
- metadata.gz: c037d9df4d7130546b3c98a925fb2b488f48a55b58e4d7ac7085418d40a8ca34ad60dde4a60a8b0af86ed1d221b72c8606f4aafe784ab9a32801d86e4e278c55
7
- data.tar.gz: ac8570cd9ff5a345508bce75e31638a27d2ef9864b453c99925dfd88245b8b7dd881e3cf1fe0c687fd22268450456328b5b9e387d2c22146d002b063d2081a99
6
+ metadata.gz: c77b213f9a399c252725fd877b9c4d8f2b02e5d6a749b64703cca51dc197ad89c54d89c1db555d44e3bf07d5b4f84461a993a18af4d394fba63d1f2e7a50ee52
7
+ data.tar.gz: 23da6ef82dbf2889c8e0cdbd671c299ae6dece1387355522c0a03c6a77dfb53cb12cb933c86d31b2f2e5637f2955429fbfc95207b5e4398ed212fb16d809f76d
data/README.md CHANGED
@@ -25,36 +25,22 @@ The checkout folder identifies the project. A separately named worktree such as
25
25
  These local `*.localhost` hostnames resolve to loopback and do not require a
26
26
  public domain, external DNS provider, or internet-facing listener.
27
27
 
28
- ## Start once per day
28
+ The [knowledge base](docs/README.md) connects the [core requirements](docs/requirements/effective-gateway.md), lifecycle ownership, and concrete developer examples for ELCC, WRAP, Travel Authorization, and Traditional Knowledge.
29
29
 
30
- Use the small repository wrapper for the common lifecycle commands:
30
+ ## Install and Start with Docker
31
31
 
32
- ```sh
33
- bin/dev up
34
- ```
35
-
36
- Check the gateway:
37
-
38
- ```sh
39
- bin/dev status
40
- ```
41
-
42
- Follow its logs:
32
+ Download [`docker-compose.yml` from release 0.4.0](https://github.com/icefoganalytics/local-development-gateway/releases/download/v0.4.0/docker-compose.yml) into a stable installation directory, then run:
43
33
 
44
34
  ```sh
45
- bin/dev logs
35
+ docker compose -p local-gateway -f docker-compose.yml up -d --wait
36
+ docker compose -p local-gateway -f docker-compose.yml ps
46
37
  ```
47
38
 
48
- Stop it only when no participating local project needs it:
39
+ Docker pulls the digest-pinned router and Traefik images. No gateway checkout, host Ruby, or npm installation is needed. The router image targets Linux amd64; Docker Compose 2.20.2 or newer is required. Windows/macOS behavior is not yet verified.
49
40
 
50
- ```sh
51
- bin/dev down
52
- ```
41
+ Ports `80`, `1433`, and `5432` on `127.0.0.1` must be free. The gateway never publishes a non-loopback listener. Follow [Docker-only installation](docs/guides/docker-installation.md) for status, logs, coordinated upgrades, and rollback.
53
42
 
54
- The wrapper also passes unrecognized arguments directly to `docker compose`, so
55
- `bin/dev config` and `bin/dev up --force-recreate` remain available.
56
-
57
- Port `80` on `127.0.0.1` must be free before starting. The gateway never binds to a non-loopback address.
43
+ For automatic startup and last-consumer shutdown through a project's existing `bin/dev`, use the optional Ruby integration below. Raw Compose shutdown has no unused-gateway guard; do not put it in consumer teardown hooks.
58
44
 
59
45
  ## Install as a gem
60
46
 
@@ -62,13 +48,12 @@ Consuming projects do not need a gateway checkout. Add the released gem to
62
48
  their bundle and pin the compatible minor version:
63
49
 
64
50
  ```ruby
65
- gem "local-development-gateway", "~> 0.3.0"
51
+ gem "local-development-gateway", "~> 0.4.0"
66
52
  ```
67
53
 
68
54
  Published gem: [`local-development-gateway`](https://rubygems.org/gems/local-development-gateway)
69
55
 
70
- The gem packages the gateway Compose file and pinned Traefik configuration.
71
- Its executable provides the same lifecycle commands:
56
+ The gem packages the image-based Compose file and coordinates the shared gateway's lifecycle. Its executable provides these commands:
72
57
 
73
58
  ```sh
74
59
  bundle exec local-development-gateway up
@@ -79,7 +64,7 @@ bundle exec local-development-gateway down
79
64
 
80
65
  `local-development-gateway` uses the installed asset path, the
81
66
  `local-gateway` Compose project and network labels, and the pinned minimum Ruby
82
- version declared by the gem. Use `~> 0.3.0` for the private database alias API below.
67
+ version declared by the gem. Version `0.4.0` includes the private database alias API below.
83
68
  The repository's `bin/dev` is only a thin wrapper around this executable API.
84
69
 
85
70
  ### Ruby API lifecycle
@@ -101,9 +86,13 @@ command that must not start a missing gateway, pass
101
86
  `ensure_running: false`; the block still runs and unused-gateway cleanup is
102
87
  attempted.
103
88
 
89
+ Version 0.4.0 coordinates operations per user and Docker daemon. The last active consumer's cleanup stops only the routers, preserving the gateway network, passive database servers, and data. Update every cooperating consumer's gateway gem before relying on this coordination; old clients do not use its locks. Adopt the active/passive labels shown in the [consumer examples](docs/guides/consumer-developer-examples.md).
90
+
91
+ For desktop-only access, use `local-development-gateway hold dbeaver`, then `local-development-gateway release dbeaver`. A named hold keeps the gateway running until deliberately released; it is not connection-triggered activation.
92
+
104
93
  ### Installed versus active versions
105
94
 
106
- `bundle exec local-development-gateway status` reports the invoking gem's installed version separately from each running shared service's active version, provenance, and mounted asset path. Healthy CLI `up`/`ensure` reuse also prints these diagnostics without recreating containers. Ruby callers can inspect `LocalDevelopmentGateway.status`; `ensure_running` still returns `:reused` for healthy services, and `ready?` remains a health check, not an artifact-version check.
95
+ `bundle exec local-development-gateway status` reports the invoking gem's installed version separately from each running shared service's active version and provenance. Healthy CLI `up`/`ensure` reuse also prints these diagnostics without recreating containers. Ruby callers can inspect `LocalDevelopmentGateway.status`; `ensure_running` still returns `:reused` for healthy services, and `ready?` remains a health check, not an artifact-version check.
107
96
 
108
97
  For the database router, the active version comes from a record written by the Ruby process after loading the library at startup. For the HTTP gateway, it is the gateway configuration artifact version recorded in a container-creation label, not the Traefik image version. Missing records or labels are `unknown`. A legacy mount path containing a gem version is useful diagnostic evidence but does not prove which Ruby code or configuration the running process loaded. Neither version record is a content hash or proof that bind-mounted files have remained unchanged.
109
98
 
@@ -363,8 +352,10 @@ bundle exec ruby "$(bundle show syntax_tree)/exe/stree" check \
363
352
  lib/local_development_gateway/database_router/tds/*.rb \
364
353
  lib/local_development_gateway/version.rb \
365
354
  bin/dev \
355
+ bin/database-router \
366
356
  bin/local-development-gateway \
367
357
  examples/database-aliases/compose.rb \
358
+ examples/shared-databases/bin/dev \
368
359
  test/*.rb \
369
360
  test/database_router/*.rb \
370
361
  test/database_router/drivers/*.rb \
@@ -377,7 +368,7 @@ rake test
377
368
 
378
369
  Each participating project installs the published gem through its existing dependency and development-wrapper workflow. Its wrapper can start or reuse the shared gateway before starting application services. A primary checkout can use `http://example.localhost`, while a separate worktree uses `http://issue-123.example.localhost`. Routed API or mail services can use corresponding `api.` or `mail.` prefixes when the consumer supplies those labels.
379
370
 
380
- Application shutdown stops that checkout's services. A wrapper using the gateway lifecycle helper removes the shared gateway only when no other running consumer needs it. Hostname derivation and application lifecycle commands remain consumer responsibilities; the gem does not prescribe a particular application wrapper or rewrite its settings.
371
+ Application shutdown stops that checkout's services. The coordinated lifecycle helper stops the shared routers only when no active consumer, pending operation, or named desktop hold remains; it preserves the shared network and database data. Hostname derivation and application lifecycle commands remain consumer responsibilities; the gem does not prescribe a particular application wrapper or rewrite its settings.
381
372
 
382
373
  The gateway owns the single browser port on `127.0.0.1:80`. Participating projects keep service ports internal to Docker and route browser traffic with explicit Traefik labels.
383
374
 
@@ -442,6 +433,13 @@ It mounts the Docker socket so it can discover labelled containers. A read-only
442
433
  | A project uses normal ports unexpectedly | Confirm the gateway container is running and has `local-gateway=true`. |
443
434
  | Authentication rejects a local URL | Check the consumer's configured application URL and identity-provider registration for the selected hostname. |
444
435
 
436
+ ## Release 0.4.0
437
+
438
+ - Install from one Compose file with digest-pinned images and no host Ruby requirement for the routers.
439
+ - Coordinate first-consumer startup, last-consumer shutdown, overlapping operations, and named desktop-client holds through the optional Ruby integration.
440
+ - Preserve passive database servers, shared networking, and data during ordinary gateway shutdown.
441
+ - Provide source-backed adoption designs for ELCC, WRAP, Travel Authorization, and Traditional Knowledge, plus a runnable shared-database example. Consumer migration and real-application RAM savings are not established by this release.
442
+
445
443
  ## Release 0.3.3
446
444
 
447
445
  - Describe historical verification with generic server roles and checkout hostnames, preserving the tested versions and outcomes without consumer-specific identifiers. Runtime and runnable examples are unchanged.
data/docker-compose.yml CHANGED
@@ -2,55 +2,54 @@ name: local-gateway
2
2
 
3
3
  services:
4
4
  gateway:
5
- image: traefik:v3.7.8
5
+ image: traefik:v3.7.8@sha256:4299bbed850421258fc5448c2e0e6ad350981d4d335a68de11b92448aedbefe5
6
6
  command:
7
- - --configFile=/etc/traefik/traefik.yml
7
+ - --entrypoints.web.address=:80
8
+ - --ping=true
9
+ - --providers.docker.exposedbydefault=false
10
+ - --providers.docker.network=local-gateway
8
11
  healthcheck:
9
12
  test: ["CMD", "traefik", "healthcheck", "--ping"]
10
- interval: 1s
13
+ interval: 30s
11
14
  timeout: 3s
12
- retries: 30
13
- start_period: 1s
15
+ retries: 3
16
+ start_period: 10s
17
+ start_interval: 1s
14
18
  labels:
15
19
  local-gateway: "true"
16
- local-gateway.version: "${LOCAL_DEVELOPMENT_GATEWAY_VERSION:-unknown}"
20
+ local-gateway.version: "0.4.0"
17
21
  ports:
18
22
  - "127.0.0.1:80:80"
19
23
  restart: unless-stopped
20
24
  volumes:
21
- - ./config/traefik.yml:/etc/traefik/traefik.yml:ro
22
25
  - /var/run/docker.sock:/var/run/docker.sock:ro
23
26
  networks:
24
27
  - local-gateway
25
28
 
26
29
  database-router:
27
- image: ruby:3.4.7-alpine
28
- command:
29
- - ruby
30
- - -I/app/lib
31
- - -rlocal_development_gateway
32
- - -e
33
- - File.write("/tmp/local-development-gateway-version", LocalDevelopmentGateway::VERSION); LocalDevelopmentGateway::DatabaseRouter.run
30
+ image: "${LOCAL_DEVELOPMENT_GATEWAY_IMAGE:-ghcr.io/icefoganalytics/local-development-gateway/database-router:0.4.0@sha256:df15d59030cb839c89899075033b7b54e62772f88d4d7eb470f452038f447ec4}"
34
31
  healthcheck:
35
32
  test:
36
33
  - CMD
37
34
  - ruby
38
35
  - -rsocket
39
36
  - -e
40
- - TCPSocket.new("127.0.0.1", 1433).close; TCPSocket.new("127.0.0.1", 5432).close
41
- interval: 1s
37
+ - |
38
+ TCPSocket.new("127.0.0.1", 1433).close
39
+ TCPSocket.new("127.0.0.1", 5432).close
40
+ interval: 30s
42
41
  timeout: 3s
43
- retries: 30
44
- start_period: 1s
42
+ retries: 3
43
+ start_period: 10s
44
+ start_interval: 1s
45
45
  labels:
46
46
  local-gateway: "true"
47
- local-gateway.version: "${LOCAL_DEVELOPMENT_GATEWAY_VERSION:-unknown}"
47
+ local-gateway.version: "0.4.0"
48
48
  ports:
49
49
  - "127.0.0.1:1433:1433"
50
50
  - "127.0.0.1:5432:5432"
51
51
  restart: unless-stopped
52
52
  volumes:
53
- - ./lib:/app/lib:ro
54
53
  - /var/run/docker.sock:/var/run/docker.sock:ro
55
54
  networks:
56
55
  - local-gateway
data/docs/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Gateway knowledge base
2
+
3
+ For developers integrating a checkout, start with [consumer developer examples](guides/consumer-developer-examples.md). For a machine owner installing or upgrading the gateway, start with [Docker installation](guides/docker-installation.md).
4
+
5
+ | Reader question | Canonical owner |
6
+ | --- | --- |
7
+ | What must this project accomplish? | [Core requirements](requirements/effective-gateway.md) |
8
+ | When does the shared gateway start and stop? | [Lifecycle ownership](architecture/gateway-lifecycle.md) |
9
+ | How are HTTP and encrypted database connections routed? | [Local TCP routing](architecture/local-tcp-routing.md) |
10
+ | What changes in ELCC, WRAP, Travel Authorization, and Traditional Knowledge? | [Consumer developer examples](guides/consumer-developer-examples.md) |
11
+ | How do we preserve data and roll back a shared-server migration? | [Migration guide](guides/docker-first-migration.md) |
12
+ | How can the database-isolation contract be exercised without consumer data? | [Runnable shared-database example](../examples/shared-databases/README.md) |
13
+
14
+ Requirements and architecture describe intended meaning and ownership; implementation defines current behavior. Tests, PRs, and release records establish observed compatibility and delivery status. Instructions for a candidate artifact do not establish that it is published or installed, and source-backed consumer examples do not establish completed adoption.
15
+
16
+ This is a public repository. Include only public guidance and sanitized contracts, never consumer secrets, backups, or copied private source. Linked private repositories retain their own access controls. No documentation site is configured; a future site must explicitly select public input rather than publish every local file.
@@ -0,0 +1,39 @@
1
+ # Gateway lifecycle ownership
2
+
3
+ The lifecycle connects the developer's existing `bin/dev` command to one shared Docker Compose gateway. The routers remain self-contained containers; the existing consumer-side Ruby wrapper coordinates their use. Docker itself must already be running. This is not browser-triggered activation, a host service manager, or a database provisioning service.
4
+
5
+ ## Three independent owners
6
+
7
+ | Owner | Starts and stops | Must preserve |
8
+ | --- | --- | --- |
9
+ | Machine gateway | HTTP and database routers | Shared gateway network and consumer data during ordinary idle-stop |
10
+ | Project database stack | That project's shared server processes | Databases/credentials belonging to every checkout |
11
+ | Checkout wrapper | Its app, worker, and one-off command containers | Neighboring apps, project servers, and stored data |
12
+
13
+ `with_running` protects a command from before gateway startup until that command returns. After a successful `up`, running app containers retain the gateway. After `down`, cleanup checks whether another consumer, pending command, or desktop hold remains. With none left, it uses Compose `stop`, not `down`: stopped router containers and the external gateway network remain available for the next startup. Database servers and their volumes are never part of that stop command.
14
+
15
+ ## What retains the gateway
16
+
17
+ A running non-gateway container attached to `local-gateway` retains it unless the container explicitly has `local-gateway.lifecycle: passive`. Missing, misspelled, and unknown label values are not passive. This conservative default preserves legacy consumers.
18
+
19
+ A running container labeled `local-gateway.lifecycle: consumer` also retains it when attached only to its project's private network. Apply that label to app/job/test services whose ordinary lifecycle should count. Shared database servers may be passive; an active worker is not passive merely because it has no HTTP route. Stopped containers do not retain the gateway.
20
+
21
+ A named desktop hold retains the gateway without an app. `hold dbeaver` ensures readiness and creates a durable hold; `release dbeaver` removes it and performs guarded cleanup. Names are idempotent keys, not incrementing reference counts. Independent users of a hold need distinct names. A live database TCP connection is not automatically a hold, and a stopped router does not wake when a client connects.
22
+
23
+ ## Concurrent operations and failure
24
+
25
+ The client uses private local state under `~/.local/state/local-development-gateway`, partitioned by a hash of the Docker daemon ID. A short exclusive coordinator lock protects startup, registration, hold changes, and shutdown decisions. Each pending operation keeps its own lock while the project command runs outside the coordinator lock, so long commands do not block unrelated checkout commands.
26
+
27
+ Under the coordinator lock, a later operation can reclaim an unlocked stale operation file. Process death releases the OS lock; no PID reuse heuristic, reference counter, background reaper, or timeout can accidentally expire a live operation. Named holds deliberately survive process exit and must be explicitly released. Surviving running consumers remain visible through Docker. If a wrapper is forcibly killed before its child creates a container, its parent-owned operation lock no longer protects that child: terminate/reconcile the interrupted command before relying on another teardown.
28
+
29
+ Failure to establish the daemon identity, acquire locks, or inspect active consumers does not authorize shutdown. Errors propagate rather than pretending cleanup succeeded. If the protected command already raised, cleanup does not replace its original exception. A teardown call with `ensure_running: false` does not start an absent gateway, but still requires a working daemon and coordination directory before running its block.
30
+
31
+ The block must wait for its project subprocess and propagate its failure. `exec` would replace Ruby and bypass block cleanup; asynchronous detached work must establish a running consumer before the block returns. The CLI `with-running [--no-start] -- COMMAND` supplies waiting execution and preserves command exit status. Direct `up`, guarded `down`, `hold`, and `release` use the same coordinator. Raw Docker Compose commands and old gem clients do not.
32
+
33
+ ## Coordination boundary
34
+
35
+ Coordination covers cooperating processes for **one local OS user and one Docker daemon**. Multiple home directories, remote machines sharing a daemon, or unsupported filesystem locking do not share this safety guarantee. All consumers must update their lifecycle library during adoption. Do not delete live state files or use a different state directory to bypass a hold.
36
+
37
+ The target platforms are Linux Docker Engine and Windows/macOS Docker Desktop with Linux containers. Native Docker socket mapping, host name resolution, architecture support, and file locking need platform-specific verification. Linux evidence does not establish Windows/macOS support. SQL Server's supported host architecture is a separate constraint.
38
+
39
+ See the [core requirements](../requirements/effective-gateway.md), [four consumer examples](../guides/consumer-developer-examples.md), and [installation/rollback procedure](../guides/docker-installation.md). Release and consumer PRs own actual verification outcomes; this document defines the boundary, not a delivery claim.