R
RunPod5d ago
Tony

environment variables

how to get environment variables while build? I set variables in endpoint settings, but they are not available during build. Please tell me if I missed something?
...
RUN python setup.py

# copy models
COPY ./models .

# Entrypoint
CMD ["python", "-u", "handler.py"]
...
RUN python setup.py

# copy models
COPY ./models .

# Entrypoint
CMD ["python", "-u", "handler.py"]
use_auth_token = os.getenv("HF_TOKEN")
print(f"Downloading model - {use_auth_token}")

snapshot_download(...)
use_auth_token = os.getenv("HF_TOKEN")
print(f"Downloading model - {use_auth_token}")

snapshot_download(...)
result:
[INFO] #13 13.75 Downloading model - None
[INFO] #13 13.75 Downloading model - None
No description
Solution:
You can either build the Docker image yourself, push to a docker registry and deploy from there. Or if you want to use the Github Integration you need to put your key inside the Dockerfile, this is the current solution.
Jump to solution
3 Replies
Eren
Eren5d ago
Environment Variables are not available during build time .They are only available on runtime.
Tony
TonyOP5d ago
Does this mean I need to add the token to the Dockerfile? I load it at build time so that it remains in the image and I don’t have to download it on every request. Are there other ways to accomplish this?
Solution
Eren
Eren5d ago
You can either build the Docker image yourself, push to a docker registry and deploy from there. Or if you want to use the Github Integration you need to put your key inside the Dockerfile, this is the current solution.

Did you find this page helpful?