Skip to content

Allow docker-compose files to override the LGTM service#223

Merged
zeitlinger merged 2 commits into
mainfrom
override-lgtm
Feb 12, 2026
Merged

Allow docker-compose files to override the LGTM service#223
zeitlinger merged 2 commits into
mainfrom
override-lgtm

Conversation

@zeitlinger

@zeitlinger zeitlinger commented Feb 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace the include: directive with multiple -f flags when merging docker-compose files
  • The include: approach treats each file as an independent project, preventing service name overrides across files (fails with services.lgtm conflicts with imported resource)
  • Multiple -f flags allow later files to merge into services defined by earlier files
  • Add --project-directory based on the first user compose file so that relative paths (build contexts, dockerfiles) resolve correctly

Motivation

This is needed for docker-otel-lgtm OBI support, where the OATS compose file must override the lgtm service to add privileged: true, pid: "host", and ENABLE_OBI: "true" for eBPF instrumentation.

Test plan

  • Verified OBI example (oats examples/obi) passes with this change
  • Verified existing Go example generates identical compose output (no regression)

Replace the `include:` directive with multiple `-f` flags when merging
docker-compose files. The `include:` approach treats each file as an
independent project, preventing service overrides across files. Multiple
`-f` flags allow later files to merge into services defined by earlier
files.

Also adds `--project-directory` based on the first user compose file so
that relative paths (build contexts, dockerfiles) resolve correctly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates how OATS generates the final docker-compose file so that user-provided compose files can override the built-in lgtm service definition (needed for OBI/eBPF scenarios), while also ensuring relative paths in user compose files resolve correctly during the merge step.

Changes:

  • Replaced the include:-based merge approach with docker compose using multiple -f flags to enable service overrides across files.
  • Added --project-directory (derived from the first user compose file) when running docker compose ... config to resolve relative build contexts/dockerfiles correctly.
  • Removed the now-unused embedded docker-compose-include-base.yml file.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
yaml/generator.go Switches compose merging to multiple -f flags and sets --project-directory for correct relative path resolution.
yaml/docker-compose-include-base.yml Removes the deprecated include: base file used by the previous merge approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread yaml/generator.go Outdated
Comment on lines +85 to +95
// uses docker compose to merge templates (multiple -f flags allow service overrides)
args := []string{"compose"}
// Set project directory from the first user compose file so that relative
// paths (build contexts, dockerfiles, etc.) resolve correctly.
if len(compose.Files) > 0 {
args = append(args, "--project-directory", filepath.Dir(compose.Files[0]))
}
for _, file := range files {
args = append(args, "-f", file)
}
args = append(args, "config")

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

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

The new docker compose merge behavior (ordering of multiple -f files and --project-directory selection) isn’t covered by unit tests. generator_test.go currently only exercises joinComposeFiles, while the production path uses docker compose ... config and now relies on --project-directory to make relative build contexts/dockerfiles resolve correctly. Consider extracting argument construction into a small helper and adding a unit test that asserts the arg list (base template first, user compose files later, and --project-directory derived from the first user compose file).

Copilot uses AI. Check for mistakes.
Address PR review feedback by extracting the docker compose argument
construction into a testable helper function with unit tests covering
both with and without user compose files.
@zeitlinger zeitlinger merged commit 54ccf21 into main Feb 12, 2026
9 checks passed
@zeitlinger zeitlinger deleted the override-lgtm branch February 12, 2026 18:01
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