Skip to content

Load and export .env variables from the mounted directory - #124

Draft
dmalan with Copilot wants to merge 3 commits into
mainfrom
copilot/add-support-for-env-file
Draft

dmalan with Copilot wants to merge 3 commits into
mainfrom
copilot/add-support-for-env-file

Conversation

Copilot AI commented Sep 24, 2026 •

Copy link
Copy Markdown

If the mounted directory contains a .env, cli50 now sources it before launching the container and exports the resulting variables into docker run. This lets project-local environment configuration flow into the container without requiring explicit --env flags.

  • Behavior

    • Detect <mounted-directory>/.env during container startup.
    • Source it in a clean shell environment.
    • Forward variables introduced or changed by that file as --env entries to the container.
    • Exit early if the .env exists but cannot be sourced.
  • Implementation

    • Add env_options(directory) in cli50/__main__.py.
    • Capture a baseline environment, source .env, then diff the result to avoid forwarding shell-added defaults like PWD or SHLVL.
    • Append the resulting --env KEY=VALUE pairs to the existing Docker run options.
  • Coverage

    • Add focused tests for:
      • no .env present
      • .env with standard assignments and quoted/exported values
# <mounted-directory>/.env
FOO=bar
export BAZ="qux quux"

This now results in the container receiving:

--env FOO=bar --env BAZ="qux quux"

Copilot AI linked an issue Sep 24, 2026 that may be closed by this pull request
Co-authored-by: dmalan <788678+dmalan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for .env file in cli50 Load and export .env variables from the mounted directory Sep 24, 2026
Copilot AI requested a review from dmalan September 24, 2026 15:45

@dmalan dmalan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add comments to your blocks of code. Omit test file for now.

Co-authored-by: dmalan <788678+dmalan@users.noreply.github.com>

Copilot AI commented Sep 24, 2026

Copy link
Copy Markdown
Author

Add comments to your blocks of code. Omit test file for now.

Addressed in ca00d09: added inline comments to the new .env blocks in cli50/__main__.py and removed the test file.

Copilot AI requested a review from dmalan September 24, 2026 15:57
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.

Add support for .env file

2 participants