Skip to content

feat: implement Docker stack module for local backend management#42

Draft
Yasirunet wants to merge 24 commits into
developmentfrom
feat/docker-stack-integration
Draft

feat: implement Docker stack module for local backend management#42
Yasirunet wants to merge 24 commits into
developmentfrom
feat/docker-stack-integration

Conversation

@Yasirunet

@Yasirunet Yasirunet commented May 11, 2026

Copy link
Copy Markdown
Contributor

feat: implement Docker stack module for local backend management

Branch: feat/docker-stack-integrationdevelopment

Summary

  • Add postkit stack module that manages Postgres, Keycloak, PostgREST, and Traefik as a Docker Compose project with a two-phase startup (infra first, app services after DB is initialized)
  • Implement is_initial DB-backed state so realm import and JWKs fetch only run on first stack up (auto-resets when volumes are wiped with stack down --volumes)
  • Add comprehensive unit tests (8 files, ~130 tests) and E2E tests (3 files, 21 tests) for all stack services, utils, and commands; update all developer and user-facing documentation

Changes

  • New modulecli/src/modules/stack/ with commands: up, down, status, logs, restart, keys, realm
  • Two-phase stack up — postgres+traefik start first → applyStackDeploy (infra SQL + migrations + seeds, hard failure) → keycloak+postgrest start
  • is_initial flag — stored in postkit.stack_config table (postkit schema); resets automatically on stack down --volumes
  • postkit init — requires project name (generates <name>_<hex>), scaffolds db/infra/001_roles.sql + 002_schemas.sql, copies Keycloak provider JARs to .postkit/auth/providers/
  • Keycloak providers — bundled JAR (vendor/providers/primary-role-mapper-1.0.0.jar) mounted at /opt/keycloak/providers; project-specific JARs supported via auth/providers/<name>/target/
  • JWT Role Mapper — injected into every non-builtin Keycloak client by cleanRealmTemplate() (idempotent)
  • Keycloak fixesKC_DB_SCHEMA: auth, Agroal pool env vars, KC_BOOTSTRAP_ADMIN_* for v26 compatibility; explicit Docker network name to allow keycloak-config-cli to join
  • stack restart — variadic service targets with name validation
  • Teststest/modules/stack/ (unit: compose, realm-init, scaffold, sync-providers, db-init, stack-config, stack-state, restart); test/e2e/ (smoke/stack-commands, error-handling/stack-config-errors, workflows/stack-init-workflow)
  • Docscli/docs/stack.md (new), updated CLAUDE.md, cli/docs/architecture.md, cli/docs/e2e-testing.md; Docusaurus stack module pages + sidebar wired

Type of Change

  • feat: New feature

Test Plan

  • Unit tests pass (npm run test)
  • E2E tests pass (npm run test:e2e) (if applicable)
  • Build succeeds (npm run build)
  • Manually tested: postkit stack up → two-phase startup, realm import, JWKs fetch; postkit stack down --volumes → resets is_initial; postkit stack restart keycloak → selective restart; postkit stack keys --restart → syncs PostgREST JWT config

Breaking Changes

  • No breaking changes

@Yasirunet Yasirunet marked this pull request as draft May 11, 2026 19:32
@Yasirunet Yasirunet requested a review from supunappri99 May 12, 2026 14:50
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 14, 2026

Copy link
Copy Markdown

Deploying postkit with  Cloudflare Pages  Cloudflare Pages

Latest commit: fcfc4ee
Status: ✅  Deploy successful!
Preview URL: https://8f85ab20.postkit.pages.dev
Branch Preview URL: https://feat-docker-stack-integratio.postkit.pages.dev

View logs

…d client credentials with automatic PostgREST updates.
…ng, and handle empty migration results gracefully
…dant healthcheck from keycloak compose config
…ory seed deployment during stack initialization
…e mapper, and move Keycloak provider syncing to initialization
@supunappri99 supunappri99 changed the title feat: stack commands feat: implement Docker stack module for local backend management Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants