Skip to content

Conversation

@betegon
Copy link
Member

@betegon betegon commented Nov 11, 2025

amongst some things, this includes:

  • setting up the env vars on the run command instead of in the docker compose specific code.
  • renaming variables
  • simplify some logic

@vercel
Copy link

vercel bot commented Nov 11, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
spotlightjs Skipped Skipped Nov 14, 2025 5:52pm

@BYK BYK changed the title Ref(sidecar): Docker compose refactor ref(sidecar): Docker compose refactor Nov 11, 2025
@betegon betegon self-assigned this Nov 11, 2025
@betegon betegon requested a review from BYK November 14, 2025 18:39
Comment on lines +193 to +201
if (choice === "docker") {
logger.info(
`Detected Docker Compose project with ${dockerCompose.serviceNames.length} service(s): ${dockerCompose.serviceNames.join(", ")}`,
);
const command = buildDockerComposeCommand(dockerCompose, actualServerPort);
// Use host.docker.internal for backend services to access the host machine
env.SENTRY_SPOTLIGHT = getSpotlightURL(actualServerPort, DOCKER_HOST);
const command = buildDockerComposeCommand(dockerCompose);
cmdArgs = command.cmdArgs;
dockerComposeOverride = command.dockerComposeOverride;
stdin = command.stdin;
Copy link
Member

Choose a reason for hiding this comment

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

Follow up: let's consolidate this logic with the else if (dockerCompose) part as we just repeat the same logic there.

// If our command has a stdin input _and_ we can send to stdin, write and close
if (stdin) {
if (!runCmd.stdin) {
logger.error("Failed to pipe Docker Compose override: stdin is not available");
Copy link
Member

Choose a reason for hiding this comment

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

We should not use Docker-specific language here as it might be a different command in the future.

Comment on lines +33 to 44
for (const baseName of COMPOSE_FILE_BASE_NAMES) {
for (const ext of COMPOSE_FILE_EXTENSIONS) {
const fileName = `${baseName}${ext}`;
try {
accessSync(fileName, constants.R_OK);
return fileName;
} catch {
// File doesn't exist or isn't readable, continue searching
}
}
}
return null;
Copy link
Member

Choose a reason for hiding this comment

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

Just musing: if you are okay with async we can actually do Promise.race(files.map(f => access(f, constants.R_OK)) or something like that and check all in parallel 😅

*/
export function findOverrideFile(composeFile: string): string | null {
// Extract extension from the original file to maintain consistency
const ext = composeFile.endsWith(".yaml") ? ".yaml" : ".yml";
Copy link
Member

Choose a reason for hiding this comment

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

We should just use COMPOSE_FILE_EXTENSIONS here? Also I think it is fair game to have docker-compose.yaml along with docker-compose.override.yml so the extensions shouldn't necessarily match.

@BYK BYK merged commit c266dd4 into main Nov 14, 2025
20 checks passed
@BYK BYK deleted the bete/docker-compose-refactor branch November 14, 2025 22:30
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.

3 participants