Skip to content

Support docker-compose for spotlight run #1089

@BYK

Description

@BYK

We want spotlight run to support docker-compose out of the box. This means the following:

  1. When no specific command is passed, we should check if:
    1. There's at least one of the following files in the directory we are in: docker-compose.yaml , docker-compose.yml, compose.yml, compose.yaml -- note which file exists, we'll use it later
    2. If we have a docker-compose or docker command executable in the PATH
    3. If we can successfully run docker-compose version or docker compose versionrespectively
    4. The version should be above (figure this out) -- we also know we need at least Docker version 20.04
  2. If we pass step 1 above, we then should:
    1. Set the run command to docker compose up or docker-compose up accordingly. Preference should be for docker-compose. Follow the logic in https://github.com/getsentry/self-hosted/blob/6ae40d837a78c2968a28acf952b1beb9911237f8/install/dc-detect-version.sh#L33
    2. Extend the command in step 2.1 above with -f <filename_from_step_1.1>
    3. Based on the file name in step 1.1 above, check if a file with the suffix .override.yml or .override.yaml based on the original filename. If it does, note the file name.
    4. If a matching file is found on step 2.3 above, extend the command from 2.2 with -f <filename_from_step_2.3>
    5. Parse the file from 1.1 (you'll need a YAML parser), get all the key names under services and note this down
    6. Generate a yaml file in memory, using all the keys from step 2.5 above with the following format:
      services:
        <key1>:
          environment:
            - SENTRY_SPOTLIGHT
            - SENTRY_TRACES_SAMPLE_RATE
          extra_hosts:
            - "host.docker.internal:host-gateway"
        <key2>:
          environment:
            - SENTRY_SPOTLIGHT
            - SENTRY_TRACES_SAMPLE_RATEy
          extra_hosts:
            - "host.docker.internal:host-gateway"
        ...
        <keyN>:
          environment:
            - SENTRY_SPOTLIGHT
            - SENTRY_TRACES_SAMPLE_RATE
          extra_hosts:
            - "host.docker.internal:host-gateway"
    7. Add the following to the final version of the command from step 2.4 above: -f - -- This is following the merge logic from https://docs.docker.com/compose/how-tos/multiple-compose-files/merge, feel free to refer to that for any corrections or debugging
    8. Change localhost in Spotlight URL to host.docker.internal so SENTRY_SPOTLIGHT env variable should be something like http://host.docker.internal:<port>/stream
    9. Push the yaml file generated in step 2.6 above as stdin for the process you are running ast part of spotlight run

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions