https://infracost.io logo
#general
Title
# general
a

average-balloon-47336

05/20/2021, 8:17 AM
Hey! I'm trying to run the Infracost binary in my own Docker image and I'm running the container as non-root which leads to some issues. Apparently Infracost tries to write to
/root/.config/infracost/.state.json
, where I assume
root
was picked due to it choosing the homedir judging by this. Any advice on how to tackle this?
l

little-author-61621

05/20/2021, 8:21 AM
Hey! Does it work if you set a different $HOME env var?
Also, do you have an example Dockerfile?
a

average-balloon-47336

05/20/2021, 8:24 AM
Hey! Does it work if you set a different $HOME env var?
Yes, it does! I'm essentially doing this with a Golang base image.
Copy code
RUN set -ex \
 && curl --fail --silent --show-error --location --remote-name "<https://github.com/infracost/infracost/releases/download/v${INFRACOST_VERSION}/infracost-linux-amd64.tar.gz>" \
 && echo "${INFRACOST_SHA256SUM} infracost-linux-amd64.tar.gz" | sha256sum -c - \
 && tar xf infracost-linux-amd64.tar.gz && mv infracost-linux-amd64 /tf-bin/infracost \
 && chmod +x /tf-bin/infracost \
 && rm -f infracost-linux-amd64.tar.gz
l

little-author-61621

05/20/2021, 8:34 AM
Great! Yeah I think setting that env var is probably the best option
👍 1
w

white-airport-8778

05/20/2021, 9:33 AM
@average-balloon-47336 curious if this is for a CI/CD integration? if so, which CI system do you use?
a

average-balloon-47336

05/20/2021, 9:34 AM
It is, we're using Buildkite.
w

white-airport-8778

05/20/2021, 9:41 AM
Great! let us know how it goes, I’m working on the Azure DevOps integration just now so happy to help…Someone else added this issue, they were using AWS with STS tokens so needed to pass those envs and mount their code to the container.
a

average-balloon-47336

05/20/2021, 1:49 PM
We sort of have a homebrewed setup that is a bit of a mess to work with. 😅 Otherwise I can't see the use of Infracost in Buildkite being particular hard.
👍 1
10 Views