Add logic to carma script to account for env var in carma-config #2408
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.
PR Details
Description
This PR fixes the carma script to be able to run from any directory without relying on .env file to exist in the same directory.
Depends on this PR: usdot-fhwa-stol/carma-config#352
The proposed change on a high level:
.env
file into thecarma-config
container. (previously it didn't exist insidecarma config edit
for example).carma *
script is run, parse all variables inside the.env
file from the carma-config image set through volumedocker-compose.yml
to run the individual services. This should work for any environment variables specified, not justDOCKER_TAG
orDOCKER_ORG
since some services require different org/tagging such asOPS
orv2xhub
etc.Resulting behavior:
.env
file in host dir wherecarma
is called will no longer work unless the.env
file in carma-config was NOT able to replace. Then the local .env file will takeover using docker's native functionality and the variables in the docker-compose.yml wil be replaced. This is desirable for simulation runs for example where multiple variables such as ROUTE_FILE are specified in .env filecarma config edit
and modify the/opt/carma/vehicle/config/.env
file and restart. The change should persist as howcarma config edit
normally works. Or even hardcoding as before in the docker-compose.yml work as well.Related GitHub Issue
NA
Related Jira Key
https://usdot-carma.atlassian.net/browse/ARC-82
Motivation and Context
During 4.5.0 release, we modifed the way DOCKER_ORG and DOCKER_TAG are specified by centralizing them into a single .env file in each carma-config folder for docker-compose.yml to load. However, currnently, when a carma-config image is built by our GitHub Actions CI processes, the resulting image still contains the {DOCKER_ORG} and {DOCKER_TAG} environment variable placeholders in the docker-compose.yml and docker-compose-background.yml files. This breaks the carma config install functionality of the carma shell script. The carma start all functionality breaks with this as well.
Workaround: If .env file exists in the same directory from where
carma
is called, then everything works fine. However, this is not a desired functionality as we want to call carma from anywhere.How Has This Been Tested?
locally in VM. Results of each commands working:
file:
![image](https://private-user-images.githubusercontent.com/20613282/339891859-5bc7ab74-0c6f-4974-b106-926c3242502d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4MjA4MjQsIm5iZiI6MTcyNTgyMDUyNCwicGF0aCI6Ii8yMDYxMzI4Mi8zMzk4OTE4NTktNWJjN2FiNzQtMGM2Zi00OTc0LWIxMDYtOTI2YzMyNDI1MDJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDE4MzUyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk4ZjAyM2E2YmZkYmNkZGNjMjg1ZTkyNTBmNDY1Y2EyMzYzN2I5ZTdhMmUxY2RjZWU4Y2JjN2JjMDM1NmQ5N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.L-MsRoUVhKTrVfletivAQhhDJ7Jk4atfuLAs8WVXW-c)
![image](https://private-user-images.githubusercontent.com/20613282/339891896-f8154351-10c0-4858-b65f-b330faed7a4a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4MjA4MjQsIm5iZiI6MTcyNTgyMDUyNCwicGF0aCI6Ii8yMDYxMzI4Mi8zMzk4OTE4OTYtZjgxNTQzNTEtMTBjMC00ODU4LWI2NWYtYjMzMGZhZWQ3YTRhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDE4MzUyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ5NDJkYmFhZDE3YzMyYjM3MmE4OThkZjU5NmQ3YzY4MGQ5MTkwNzJlNzdmMzZkNmQ0YjlkZGRjZjc2MGY1OGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.rtm1AraoQqLaAKmWn1l-bfVgas_H89IZHtaQnmUXiDM)
carma command results.txt
in colored:
Types of changes
Checklist: