Plain containers and external ports
A TypeScript server built with Hono that logs in with OpenID Connect against a mock provider, where each lane runs its own provider. The containers run without a Compose file, and devlanes.local.example.yaml routes a hostname to a docs server you start yourself with devlanes exec.
Requirements
Section titled “Requirements”- devlanes, with
devlanes setuprun once - Node 22 or later
- Docker
Run it
Section titled “Run it”cd infra-plain-containersdevlanes startOpen https://example-plain-containers.localhost. The page says This is lane 0 of example-plain-containers. and shows the issuer of the lane’s OIDC provider and the hostname of the shared whoami container; the login button goes to the provider’s login form at https://auth.example-plain-containers.localhost/default/authorize, and any username brings you back with the ID token’s claims (sub, iss, preferred_username, email, roles).
During a start
Section titled “During a start”The first start of lane 0, with devlanes start --no-ui --output plain:
ok infraok installexample-plain-containers@0 · mainok services 1 of 1 ready ok web https://example-plain-containers.localhost- Infra: devlanes runs the containers bound to 127.0.0.1.
devlanes-example-plain-containers-lane0-oidcis lane 0’s own provider (ghcr.io/navikt/mock-oauth2-server:6.1.1) withinfra/oidc.jsonbind-mounted read-only;devlanes-example-plain-containers-whoamihas noper_lane, so there is one for the whole project. Each named port inportsgets a host port, read as${{ infra.oidc.ports.http }}and${{ infra.whoami.ports.http }}. The start waits for each container’sready.httpcheck:/isaliveon the provider,/healthon whoami. lane.createtasks:installrunsnpm install.- Services:
webrunsnpm run dev(tsx watch src/index.ts) withOIDC_ISSUER,OIDC_PORTandWHOAMI_URLfromglobal_envandPUBLIC_URLfrom${{ self.public_url }}, and is ready when/healthzanswers.
Provider hostname and issuer
Section titled “Provider hostname and issuer”infra.hosts routes auth.example-plain-containers.localhost to the provider’s http port. The provider names its issuer after the host and scheme each request came in with. The devlanes proxy keeps the Host header and sends X-Forwarded-Proto: https, so through the proxy the issuer is https://auth.example-plain-containers.localhost/default. That is the issuer the browser logs in at, so src/oidc.ts uses the same hostname for discovery and the code exchange (with openid-client), over HTTPS trusted through the NODE_EXTRA_CA_CERTS devlanes sets for Node. On its host port the same provider names another issuer, and the ID token’s iss would follow it:
curl -s http://127.0.0.1:20541/default/.well-known/openid-configuration{ "issuer" : "http://127.0.0.1:20541/default", "authorization_endpoint" : "http://127.0.0.1:20541/default/authorize",devlanes infra status prints the host port to use in place of 20541. The callback goes to PUBLIC_URL plus /callback, so each lane’s provider sends the browser back to that lane’s app.
Try next
Section titled “Try next”Start a second lane in a worktree:
git worktree add ../examples-checkout -b feat/checkout, thencd ../examples-checkout/infra-plain-containers && devlanes start. From the same folder,devlanes lane new --name example-plain-containers-review --startgives a second lane without a worktree:ok infraok installcreated example-plain-containers@1 named example-plain-containers-review (main) at D:\acme\examplesexample-plain-containers@1 · mainok services 1 of 1 readyok web https://example-plain-containers1.localhostLane 1 at https://example-plain-containers1.localhost logs in at
https://auth.example-plain-containers1.localhost/default/authorize, and its ID token has"iss": "https://auth.example-plain-containers1.localhost/default". The whoami card shows the same URL and hostname in both lanes.List the containers. Each lane has its own provider, and whoami appears once:
Terminal window docker ps --filter label=dev.devlanes.project=example-plain-containers --format '{{.Names}}\t{{.Ports}}'devlanes-example-plain-containers-lane1-oidc 127.0.0.1:20561->8080/tcpdevlanes-example-plain-containers-whoami 127.0.0.1:20552->80/tcpdevlanes-example-plain-containers-lane0-oidc 127.0.0.1:20541->8080/tcpRoute a server only you run. Copy the local file and start the docs server as a unit of the lane:
Terminal window cp devlanes.local.example.yaml devlanes.local.yamldevlanes exec --name docs-server -- npm run docsnpm run docsrunssrc/scripts/docs-server.tson port 4800, the addressdevlanes.local.yamldeclares. devlanes reads the new file on its own and routes the entry right away.devlanes status 0lists it with its fixed port:docs external 4800 – – https://docs.example-plain-containers.localhosthttps://docs.example-plain-containers.localhost and https://docs.example-plain-containers1.localhost both reach the one
docs-serverprocess, and its page names the hostname each request came in on. The page’s branch row shows-, because commands run withdevlanes execdo not getLANE_LABELfromglobal_envin devlanes 0.11.3.The lane line in
devlanes statussaysconfig changed: infra changedafter that.devlanes reloadclears it by restarting the whole lane (warn infra or ports changed, so the whole lane restarted). It reuses both containers and stopsdocs-server, so run thedevlanes execcommand again afterwards.devlanes stop docs-serverstops the server. Its hostnames then answer with the proxy’sDL301 Service not listeningpage (503) until you deletedevlanes.local.yaml, which removes the routes.devlanes stopstopswebonly. Both containers keep running, and the nextdevlanes startreuses them.devlanes lane clean example-plain-containers-review --yesprintscleaned example-plain-containers@1: stopped 1 unitand removes lane 1’s provider. Thedocker pscommand above then listsdevlanes-example-plain-containers-whoamianddevlanes-example-plain-containers-lane0-oidc, and lane 0 keeps running.To remove everything:
devlanes lane clean 0 --yes, which removes lane 0’s provider, thendocker rm -f devlanes-example-plain-containers-whoamifor the shared container, whichlane cleanleaves in place. Deletedevlanes.local.yamlif you created it.
devlanes.yaml: the per-laneoidccontainer with itsauth.hostname, the sharedwhoamicontainer, the issuer and whoami URL inglobal_env,installand thewebservice.devlanes.local.example.yaml:infra.external.docsat127.0.0.1:4800with adocs.hostname in every lane; copy it todevlanes.local.yaml.infra/oidc.json: the provider’s config, mounted into each lane’s container: the login form and the claims it adds to every token.src/oidc.ts: discovery and the code flow with openid-client.src/routes/: the page, login, callback and logout, and the docs server’s app.src/scripts/docs-server.ts: the docs server, listening on the port given as its argument.