-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support local development environment variables #255
Comments
There are actually several different effects related to env vars at play here:
For the reasons explained in (3), I think making the developer responsible for loading the env vars him/herself in (2) is probably safer. But tell me if you disagree or see other benefits or downsides that I'm missing! [1] https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/
This is the case already! |
For me, a key aspect of the cookie-cutter approach is to apply and enforce best practices, ensuring a common and consistent way of working. Currently, leaving the responsibility to developers has resulted in inconsistent strategies, such as:
After evaluating various approaches, I’ve concluded that using Docker Compose's env_file directly for dev container setup is the cleanest and most practical option. This method offers a straightforward and consistent way to manage environment variables across local and cloud environments, streamlining the transition to deployment on platforms like Azure or AWS. The only requirement for developers is to restart the Dev Container whenever environment variables are updated, ensuring simplicity and reliability in the process. This approach eliminates ambiguity in managing environment variables and establishes a clear strategy. |
In combination with Docker Compose's Example usage: from typing import ClassVar
from pydantic_settings import BaseSettings, SettingsConfigDict
class RAGLiteCLIConfig(BaseSettings):
"""RAGLite CLI config."""
model_config: ClassVar[SettingsConfigDict] = SettingsConfigDict(
env_prefix="RAGLITE_", # The prefix of the environment variables to load.
env_file=".env", # Load additional env vars from this file.
extra="allow" # Whether to add nondeclared env vars as attributes to this model.
)
mcp_server_name: str = "RAGLite" # = RAGLITE_MCP_SERVER_NAME
db_url: str = "sqlite:///:memory:" # = RAGLITE_DB_URL
llm: str = "gpt-4o" # = RAGLITE_LLM
embedder: str = "text-embedding-3-large" # = RAGLITE_EMBEDDER
config = RAGLiteCLIConfig() # Loads settings from env vars and the .env file. I'm not sure we can really enforce this though. Do you think it would make sense to include |
It’s recommended to use a
.env
file to securely manage sensitive configuration information, such as API keys, database credentials, and other environment-specific variables.To ensure these configurations are used during development we should consider adding
env_file
to the devcontainer’sdocker-compose
configuration, pointing it towards the.env
file.As a result, the
.env
file should be added to the.gitignore
file to prevent accidental inclusion in version control.The text was updated successfully, but these errors were encountered: