By echoTHIS
I was following the tutorial on How to Use Environment Variables in App Platform, and I am unable to figure out how to use these convenience variables in my Dockerfile.
I am specifically trying to print the COMMIT_HASH
to a file in the container of my web
component.
ARG web.COMMIT_HASH=unspecified
RUN echo ${web.COMMIT_HASH} > /www/commithash.txt
I’ve also tried pulling it in using ENV
but that fails during build.
ENV GITHASH=${web\.COMMIT_HASH:-unspecified}
RUN echo ${GITHASH} > /www/githash.txt
It errors out at the .
dot.
So is there a way to get these convenience environment variables into my Dockerfile?
Any help is greatly appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Great question, bindable variables are a template system for environment variables, not environment variables themselves.
You could create a environment variable called GITHASH
with a value of ${web.COMMIT_HASH}
in the DO App Platform UI. When we build or deploy your app we will inject an environment variable of $GITHASH with your commit hash.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.