Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Nov 13, 2025

Addresses #1089 (comment)

This PR implements support for the COMPOSE_FILE environment variable, allowing users to specify one or more Docker Compose files via an environment variable, aligning with native Docker Compose behavior.

Key changes:

  • Prioritize COMPOSE_FILE: Spotlight now checks the COMPOSE_FILE environment variable first to determine which compose files to use.
  • Docker Compose behavior alignment: When COMPOSE_FILE is set, automatic detection of docker-compose.override.yml is skipped, matching native Docker Compose behavior.
  • Multiple file support: Supports multiple compose files specified in COMPOSE_FILE (separated by : on Unix, ; on Windows).
  • Environment cleanup: The COMPOSE_FILE variable is unset in the spawned Docker Compose process to prevent conflicts with explicitly passed -f flags.

This change allows users to specify compose files via the COMPOSE_FILE environment variable. It also ensures that the COMPOSE_FILE variable is unset after use to prevent unintended side effects.

Co-authored-by: burak.kaya <[email protected]>
@cursor
Copy link

cursor bot commented Nov 13, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@BYK BYK deployed to Preview November 13, 2025 23:03 — with GitHub Actions Active
@vercel
Copy link

vercel bot commented Nov 13, 2025

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

Project Deployment Preview Comments Updated (UTC)
spotlightjs Ready Ready Preview Comment Nov 14, 2025 8:09am

@cursor cursor bot deployed to Preview November 13, 2025 23:18 Active
@BYK BYK requested a review from betegon November 13, 2025 23:21
@BYK BYK marked this pull request as ready for review November 13, 2025 23:21
cmdArgs = command.cmdArgs;
dockerComposeOverride = command.dockerComposeOverride;
// Always unset COMPOSE_FILE to avoid conflicts with explicit -f flags
env.COMPOSE_FILE = undefined;
Copy link

Choose a reason for hiding this comment

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

Bug: Env Vars: undefined Becomes String, Not Unset

Setting env.COMPOSE_FILE = undefined will convert the environment variable to the string "undefined" in the spawned process instead of unsetting it. To properly unset an environment variable in Node.js, use delete env.COMPOSE_FILE instead.

Fix in Cursor Fix in Web

cmdArgs = command.cmdArgs;
dockerComposeOverride = command.dockerComposeOverride;
// Always unset COMPOSE_FILE to avoid conflicts with explicit -f flags
env.COMPOSE_FILE = undefined;
Copy link

Choose a reason for hiding this comment

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

Bug: The undefined Environment Variable Trap

Setting env.COMPOSE_FILE = undefined will convert the environment variable to the string "undefined" in the spawned process instead of unsetting it. To properly unset an environment variable in Node.js, use delete env.COMPOSE_FILE instead.

Fix in Cursor Fix in Web

@cursor cursor bot deployed to Preview November 14, 2025 08:08 Active
Copy link
Member

@betegon betegon left a comment

Choose a reason for hiding this comment

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

merging thiis!

@betegon betegon merged commit 671f6c3 into main Nov 14, 2025
20 checks passed
@betegon betegon deleted the cursor/implement-compose-file-environment-variable-support-9764 branch November 14, 2025 14:34
betegon added a commit that referenced this pull request Dec 1, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @spotlightjs/[email protected]

### Minor Changes

- Added spotlight sdk for helping others to build on top of it
([#1140](#1140))

- Support COMPOSE_FILE environment variable for Docker Compose projects
([#1131](#1131))

- Prompt user to choose between docker compose and package.json when
both are present
([#1120](#1120))

### Patch Changes

- Refactor docker compose support
([#1121](#1121))

- disable sentry in development mode
([#1143](#1143))

- **Security:** Restrict CORS origins for Sidecar to prevent
unauthorized access
([#1138](#1138))

    The Sidecar now only accepts requests from trusted origins:

    -   `localhost` with any port or protocol (http/https)
- `https://spotlightjs.com` and `https://*.spotlightjs.com` (HTTPS only,
default port)

⚠️ **Potentially Breaking:** If you were accessing the Sidecar from
other origins (e.g., custom domains, non-HTTPS spotlightjs.com), those
connections will now be rejected. This change improves security by
preventing malicious websites from connecting to your local Sidecar
instance.

- Fix file capture error handling to log errors instead of crashing when
SPOTLIGHT_CAPTURE is enabled
([#1142](#1142))

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Miguel Betegón <[email protected]>
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.

4 participants