You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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":
To resolve the issue with the REDACTED_BUCKET environment variable not being loaded into your Docker container, follow these steps:
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
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 locatedif [ -f /path/in/container/.env ];thensource /path/in/container/.env
fiexec python main.py
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.
Expected behavior
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":The text was updated successfully, but these errors were encountered: