Skip to content
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

[Bug] Agenta Variant container fails to start due to missing env var #1506

Closed
alanmun opened this issue Apr 12, 2024 · 2 comments
Closed

[Bug] Agenta Variant container fails to start due to missing env var #1506

alanmun opened this issue Apr 12, 2024 · 2 comments
Labels
bug Something isn't working python Pull requests that update Python code

Comments

@alanmun
Copy link

alanmun commented Apr 12, 2024

Traceback (most recent call last):
  File "/app/main.py", line 3, in <module>
    import _app  # This will register the routes with the FastAPI application
  File "/app/_app.py", line 2, in <module>
    from shared.constants import UserType
  File "/app/shared/constants.py", line 39, in <module>
    REDACTED_BUCKET= os.environ["REDACTED_BUCKET"]
  File "/usr/local/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'REDACTED_BUCKET'

Expected behavior
image

It should use the environment variables I defined in .env. This environment variable is present there, it seems that the docker container never grabbed my environment variables when deploying this variant.

docker inspect (my variant container) outputs for "Env":

            "Env": [
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D",
                "PYTHON_VERSION=3.10.14",
                "PYTHON_PIP_VERSION=23.0.1",
                "PYTHON_SETUPTOOLS_VERSION=65.5.1",
                "PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/dbf0c85f76fb6e1ab42aa672ffca6f0a675d9ee4/public/get-pip.py",
                "PYTHON_GET_PIP_SHA256=dfe9fd5c28dc98b5ac17979a953ea550cec37ae1b47a5116007395bfacff2ab9"
            ],

Copy link

dosubot bot commented Apr 12, 2024

To resolve the issue with the REDACTED_BUCKET environment variable not being loaded into your Docker container, follow these steps:

  1. Include the .env File in Your Docker Image: Ensure your Dockerfile copies the .env file into the image. Use the COPY command to place the .env file in the same directory as your application code or wherever your entrypoint.sh script expects it to be.
COPY path/to/your/.env /path/in/container/.env
  1. Modify the entrypoint.sh Script: If your .env file is located in a different spot within the container, update your entrypoint.sh script to source the .env file from its correct location.
#!/bin/bash
# Update the path to where your .env file is located
if [ -f /path/in/container/.env ]; then
    source /path/in/container/.env
fi

exec python main.py
  1. Rebuild and Run Your Docker Container: After making these adjustments, rebuild your Docker image and run your container. This ensures the REDACTED_BUCKET environment variable is correctly loaded.
docker build -t your-image-name .

This approach ensures that your Docker container correctly sources the .env file, making the REDACTED_BUCKET environment variable available to your application.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added bug Something isn't working python Pull requests that update Python code labels Apr 12, 2024
@mmabrouk
Copy link
Member

Stale. Would love more information and I could reopen this. (and sorry for missing the issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests that update Python code
Projects
None yet
Development

No branches or pull requests

2 participants