Skip to content

refactor(compose): dedupe bot+backend env vars via YAML anchor - #852

Merged
LucasSantana-Dev merged 3 commits into
release/v2.11.0from
refactor/compose-env-anchors
May 14, 2026
Merged

LucasSantana-Dev merged 3 commits into
release/v2.11.0from
refactor/compose-env-anchors

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Deduplicates shared environment variables between bot and backend services in docker-compose.yml using a YAML anchor (x-common-app-env).

  • Eliminates copy-paste drift between service env blocks
  • Single source of truth for shared vars (DATABASE_URL, REDIS_URL, etc.)
  • No runtime behavior change

The standalone `Dockerfile.frontend` re-ran `npm ci` for the entire
workspace just to build the frontend SPA, which:

1. Wasted ~10-12s per build duplicating the dep install.
2. Exposed the frontend image build to the bot's native deps
   (@discordjs/opus). PR #846 hit this when Dependabot bumped to
   `node:26-alpine` — Alpine without a C toolchain couldn't build
   opus from source, breaking `docker-publish` for 4 days.

This refactor merges frontend building into the main `Dockerfile` as
two new stages:

- `build-frontend` — inherits from existing `build` stage (which
  already has `build-base + python3-dev + opus-dev`), copies frontend
  source, runs `npm run build --workspace=packages/frontend`. Native
  compilation works here even if prebuilts are missing for the chosen
  Node major.
- `production-frontend` — `nginxinc/nginx-unprivileged:1.27-alpine`,
  copies dist from `build-frontend`, serves on :8080, includes
  HEALTHCHECK.

Wired through:
- `docker-compose.yml` frontend service → `target: production-frontend`
- `.github/workflows/docker-publish.yml` matrix entry updated
- `docs/DOCKER.md` updated
- `Dockerfile.frontend` deleted

Overrides the 12-month defer on
`docs/decisions/2026-05-13-frontend-dockerfile-keep-separate.md`. ADR
update follows in a separate commit.
The 12-month-defer ADR was hedging against a hypothetical break. PR #846
already fired the hedge's trigger condition. Consolidating now: 5 files,
~30 LOC delta, no behavior change, eliminates the structural cause.
Bot and backend share ~25 env vars (NODE_ENV, DISCORD auth, Sentry stack,
DATABASE_URL, Redis config, last.fm, Spotify, webapp secrets). Previously
each service repeated the full list with identical `${VAR:-default}`
patterns.

Extracts `x-common-app-env: &common-app-env` as a top-level mapping;
both services consume it via `environment:\n  <<: *common-app-env` +
service-specific overrides inline.

Trade: converts env from list-of-strings (`- KEY=value`) to mapping
(`KEY: value`). YAML merge keys (`<<:`) require mapping style. Compose
accepts both, no behavior change verified via `docker-compose config`.

LOC delta: docker-compose.yml shrinks ~7% (282→263). The real win is
that adding a new shared var now touches one place instead of two.
@vercel

vercel Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment May 14, 2026 5:41pm

Request Review

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 50 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 01d5cea1-ca1f-402d-aa48-778d40928586

📥 Commits

Reviewing files that changed from the base of the PR and between a44c3ef and 55f2ee3.

📒 Files selected for processing (6)
  • .github/workflows/docker-publish.yml
  • Dockerfile
  • Dockerfile.frontend
  • docker-compose.yml
  • docs/DOCKER.md
  • docs/decisions/2026-05-13-frontend-dockerfile-consolidated.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/compose-env-anchors

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 greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LucasSantana-Dev has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit ab0ff9e into release/v2.11.0 May 14, 2026
18 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the refactor/compose-env-anchors branch May 14, 2026 18:39

This branch was successfully deployed

1 active deployment
Preview — 55f2ee38 Deployed May 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant