fix (cli): implementing env vars #702
Merged
+27
−144
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.
Description
implementing docker build reading env vars
Related Issues
Closes #
Checklist when merging to main
rustfmthelix-cli/Cargo.tomlandhelixdb/Cargo.tomlAdditional Notes
Greptile Overview
Greptile Summary
This PR enables Docker containers to access embedding provider API keys by loading environment variables from
.envfiles and the shell environment. The changes allowOPENAI_API_KEYandGEMINI_API_KEYto be passed through to containers, which is necessary for the embedding functionality inhelix-db/src/helix_gateway/embedding_providers/mod.rsto work properly.Key Changes:
dotenvy::dotenv()call inenvironment_variables()to load.envfileOPENAI_API_KEYandGEMINI_API_KEYgenerate_docker_compose()to dynamically generate environment section from all variablesNotes:
.envfile loading happens every timeenvironment_variables()is called, which could be optimizedImportant Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User as User participant CLI as Helix CLI participant DM as DockerManager participant Env as Environment/.env participant Docker as Docker Compose participant Container as Helix Container participant EP as Embedding Provider User->>CLI: helix start/build CLI->>DM: generate_docker_compose() DM->>DM: environment_variables(instance_name) DM->>Env: dotenvy::dotenv() Env-->>DM: Load .env file (silent fail) DM->>Env: std::env::var("OPENAI_API_KEY") Env-->>DM: Return key if exists DM->>Env: std::env::var("GEMINI_API_KEY") Env-->>DM: Return key if exists DM->>DM: Build env_vars vec (HELIX_PORT, HELIX_DATA_DIR, etc.) DM->>DM: Format environment section DM-->>CLI: docker-compose.yml content CLI->>Docker: docker compose up Docker->>Container: Start with env vars Container->>EP: API request with OPENAI_API_KEY/GEMINI_API_KEY EP-->>Container: Embedding response