-
-
Notifications
You must be signed in to change notification settings - Fork 32
ref(sidecar): Docker compose refactor #1121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
| 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; |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
| 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; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
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]>
amongst some things, this includes: