Skip to content

ops: define paid-app service in docker-compose.prod.yml#24

Merged
rainxchzed merged 3 commits into
mainfrom
ops/paid-app-compose-service
May 26, 2026
Merged

ops: define paid-app service in docker-compose.prod.yml#24
rainxchzed merged 3 commits into
mainfrom
ops/paid-app-compose-service

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

The perf audit caught that `paid-backend/deploy.sh` runs `docker compose up -d --build paid-app` against a compose file that doesn't define a `paid-app` service. Operators have been hand-editing the block on the VPS to make deploys work — the production topology was untracked by git.

This PR moves that block into the repo so the deploy is reproducible.

Changes

  • New `paid-app` service block in `docker-compose.prod.yml`:
    • Builds from `../komi-paid-backend` (sibling deploy dir on VPS).
    • Shares the existing `postgres` container; isolates via `komistore_paid` DB.
    • `mem_limit: 1.5g` (tight; see comment for the 8 GB VPS budget breakdown).
    • `read_only` rootfs + `tmpfs /tmp` matches free-tier hardening.
    • Healthcheck via `wget` (Alpine JRE has no curl).
  • `.env.example` documents every new key required to bring paid-app up.

Pre-merge operator steps

Populate `/opt/github-store-backend/.env` on the VPS with the new `KOMI_`, `CF_`, `STRIPE_`, and `ED25519_` keys — at minimum:

  • `KOMI_PAID_DB_PASSWORD`
  • `KOMI_INTERNAL_TOKEN`
  • `INTERNAL_AUTH_ALLOWED_HOSTS`
  • `KOMI_KEY_SOURCE` + matching key-source-specific keys
  • `STRIPE_SECRET_KEY` + `STRIPE_WEBHOOK_SECRET`
  • `KOMI_STORAGE_*` (R2 credentials)

Without these, `docker compose up paid-app` will fail fast at boot with explicit env-var-missing errors (this is the AppConfig fail-fast behaviour from PR #3 on paid-backend).

Compose interaction with PR #22 (api.komistore.app vhost)

PR #22 references `paid-app:8080` in the Caddyfile. Caddy's `depends_on` block still only references `app` (free-tier) so a paid-app outage doesn't block the free-tier from starting; Caddy will return 502 for api.komistore.app traffic until paid-app is healthy.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@rainxchzed, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 20 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b29cfae4-ede7-4c72-831c-8bc00c81fd54

📥 Commits

Reviewing files that changed from the base of the PR and between 3f9880f and f47a24b.

📒 Files selected for processing (2)
  • .env.example
  • docker-compose.prod.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ops/paid-app-compose-service

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 25, 2026

Greptile Summary

This PR tracks the production paid-app service definition that was previously being hand-edited on the VPS, moving it into docker-compose.prod.yml alongside .env.example documentation for all required credentials.

  • paid-app service block added to docker-compose.prod.yml: builds from ../komi-paid-backend, shares the existing postgres container via an isolated komistore_paid database, applies matching read_only/tmpfs hardening, and uses wget-based healthcheck (Alpine JRE, no curl).
  • .env.example extended with a complete paid-tier section covering DB credentials, signing-key modes (env vs cloudflare_kv), Stripe keys, and R2 storage — with per-var commentary explaining fail-fast behaviour and when each key is required.

Confidence Score: 4/5

Safe to merge after adding a profiles guard to paid-app; without it, the existing free-tier deploy script will fail on any VPS where ../komi-paid-backend has not been synced.

The free-tier deploy.sh runs docker compose up -d --build with no service targets. Now that paid-app is in the compose file without a profiles key, every free-tier deploy attempts to build it from ../komi-paid-backend. On a VPS without that path, set -euo pipefail aborts the deploy mid-flight. The rest of the change is well-structured and consistent with existing services.

docker-compose.prod.yml — the paid-app service block needs a profiles: [paid] key before this is safe to deploy against the shared VPS.

Important Files Changed

Filename Overview
docker-compose.prod.yml Adds paid-app service block with correct postgres dependency, read_only/tmpfs hardening, and per-container env mapping; missing profiles: [paid] guard causes every free-tier deploy to attempt building paid-app from ../komi-paid-backend, breaking the deploy if that path doesn't exist.
.env.example Adds well-documented paid-tier env var section covering DB credentials, signing-key modes, Stripe, and R2 storage; accurately reflects compose defaults and operator checklist.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[deploy.sh on VPS] -->|docker compose -f docker-compose.prod.yml up -d --build| B{No service target specified}
    B -->|builds ALL services| C[app free-tier]
    B -->|builds ALL services| D[paid-app]
    B -->|builds ALL services| E[caddy / postgres / etc]

    D -->|build context| F[../komi-paid-backend]
    F -->|path missing?| G[❌ Build fails — entire deploy aborted]
    F -->|path exists| H[paid-app container starts]

    C --> I[depends_on postgres healthy]
    H --> I
    I --> J[(postgres komistore_paid DB)]

    style G fill:#ff6b6b,color:#fff
    style D fill:#ffd93d
Loading

Fix All in Claude Code

Reviews (2): Last reviewed commit: "Merge branch 'main' into ops/paid-app-co..." | Re-trigger Greptile

Comment thread docker-compose.prod.yml Outdated
Comment thread docker-compose.prod.yml
… deploy)

The paid-backend deploy script runs `docker compose ... up -d --build
paid-app` against this compose file, but the paid-app service was never
defined here — operators were hand-editing the service block on the VPS
to make deploys work. This made the production topology untracked by
git, which is exactly the kind of drift a perf audit catches.

Service block:
- Builds from ../komi-paid-backend (sibling deploy dir on the VPS).
- Shares the existing postgres container; isolates via komistore_paid DB.
- mem_limit 1.5g — tight but defensible (see comment for the 8 GB budget).
- read_only rootfs + tmpfs /tmp matches the free-tier app hardening.
- Env vars cover Stripe, R2, Cloudflare KV signing keys, and the
  internal-auth allowlist; sensible defaults so unset values fall back
  cleanly without breaking the boot of free-tier app.

.env.example documents every new key so operator setup is self-serve.
…reptile)

Greptile flagged the silent-failure path: ${KOMI_KEY_SOURCE:-cloudflare_kv}
combined with empty defaults for CF_ACCOUNT_ID / CF_KV_NAMESPACE_ID /
CF_API_TOKEN means an operator who follows the minimum env checklist but
forgets the Cloudflare vars boots a healthy-looking container that 404s
on every signing-key fetch.

Switching the compose fallback to KEY_SOURCE=env makes the missing
configuration surface immediately as 'env var ED25519_PRIVATE_KEY not
set' — a clearly-named failure tied to the actual code path. Production
deploys (which use CF KV) just set KOMI_KEY_SOURCE=cloudflare_kv
explicitly in /opt/github-store-backend/.env. The paid-backend's
SigningConfig.from additionally fail-fasts on empty CF vars when
KEY_SOURCE=cloudflare_kv, so a half-configured CF deploy crashes at
AppConfig.from() not at signing time.

Healthcheck path stands: paid-backend serves bare /health (verified at
Application.kt:195), distinct from free-tier /v1/health.
@rainxchzed rainxchzed force-pushed the ops/paid-app-compose-service branch from 6d54d24 to 2a8d0f8 Compare May 26, 2026 09:52
@rainxchzed rainxchzed merged commit 66d1a64 into main May 26, 2026
2 checks passed
@rainxchzed rainxchzed deleted the ops/paid-app-compose-service branch May 26, 2026 09:57
Comment thread docker-compose.prod.yml
Comment on lines +156 to +158
paid-app:
build: ../komi-paid-backend
restart: unless-stopped
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 The free-tier deploy.sh (line 26) runs docker compose -f docker-compose.prod.yml up -d --build with no service targets, so it will attempt to build paid-app from ../komi-paid-backend on every free-tier deploy. On any VPS where the paid-backend hasn't been synced (fresh rollout, separate free-tier host, etc.), the build step will fail with a "path not found" error and set -euo pipefail will abort the entire deploy — taking down the free-tier backend mid-deploy. Even on the shared VPS, paid-app gets rebuilt and restarted on every free-tier release, causing unnecessary disruption for paid users. Adding a profiles key restricts paid-app to opt-in runs (docker compose --profile paid up -d --build) and leaves the free-tier deploy unaffected.

Suggested change
paid-app:
build: ../komi-paid-backend
restart: unless-stopped
paid-app:
build: ../komi-paid-backend
restart: unless-stopped
profiles: [paid]

Fix in Claude Code

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.

1 participant