1

I am building a web application that makes use of the Pulumi automation SDK. The application is to be deployed within a linux docker container, so I added the following lines to the Dockerfile:

RUN curl -fsSL https://get.pulumi.com | sh
ENV PATH="/root/.pulumi/bin:${PATH}"

However, it looks like the Pulumi CLI is not available in bash after the image is built. I have validated that the Pulumi executables were indeed installed into /root/.pulumi/bin

I suspect that the cause is pulumi installed into the /root folder rather than to ~/ but I am not sure how to fix it.

Thanks

Avi Nehama
  • 103
  • 1
  • 8
  • If the binaries are there, then it sounds like your container isn’t seeing your change to PATH. What happens if you run it straight from the that folder (so cd to that folder and run it)? – Piers Karsenbarg Sep 02 '21 at 09:20
  • @PiersKarsenbarg printing the path with `echo $PATH` shows that the path does include the relevant folder (/root/.pulumi/bin). In addition, if I run the command`sudo /root/.pulumi/bin/pulumi` then the Pulumi cli is invoked properly. – Avi Nehama Sep 02 '21 at 09:40
  • What error are you getting? Maybe it's a permissions thing. What user is running Pulumi? Do /root and /root/.local have a+rx permission? – Paul Hicks Sep 09 '21 at 02:00

1 Answers1

0

Faced the same problem and your suspicion is correct - when Dockerfile is being built all steps are executed as root. When you use the container you run as a different user. I've ended up copying files to different folder as part of the Dockerfile build process:

RUN curl -fsSL https://get.pulumi.com | sh 
RUN mkdir /usr/bin/.pulumi && mv /root/.pulumi/* /usr/bin/.pulumi/ 
ENV PATH "$PATH:/usr/bin/.pulumi/bin/"

This is also ho Klotho is doing it for their docker: https://github.com/klothoplatform/docker-klotho/blob/main/Dockerfile.

Miczi
  • 136
  • 1
  • 6