feat: add environment variable representing the path to the build context #16311
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds an environment variable to the build context of the Docker images for metricbeat's integrations. This variable, named after service's name appending '_PATH' (uppercase, i.e. APACHE_PATH), will have a default value of '.', which is the current value to all of them.
Why is it important?
We'd like to align the docker compose files in the end-2-end tests PoC (https://github.com/elastic/metricbeat-tests-poc) with those located in the Beats repo, so that we consume the same artifacts with same configurations.
The reason why it is not possible before these changes is because of Docker Compose's expected behavior: when using multiple docker-compose files (as we do in the PoC), any relative path in the build-chain must be discoverable by the first
-f compose.yml
element (See docker/compose#3568 and docker/compose#3874). With current approach, existing compose files cannot be consumed by anybody else but Beats, as it expects having access to the./_meta
from the build context. (See https://github.com/elastic/beats/blob/master/metricbeat/module/apache/docker-compose.yml#L1-L11)Because of that, from PoC perspective, where we want to consume same compose files, we need a manner to discover each
_meta
directory from a first compose file, and the easiest manner is to override an environment variable with the path to the compose, which is known in runtime by the PoC, so it's able to put the proper value, resolving each_meta
directory for each integration.Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature worksAuthor's Checklist
How to test this PR locally
From metricbeat directory, run
mage compose:buildSupportedVersions
, the process should finish successfully.Build Log
Related Issues