I'm trying to build a simple docker image with tfswitch installed. I tried it running locally on my Mac OSX by running curl and executing tfswitch 0.12.24 to install v0.12.24 of terraform. It works perfectly fine there. However, I need to create a Docker image out of it and it keeps failing. The tfswitch seems to be added to the image but the RUN /usr/local/bin/tfswitch 0.12.24 fails with an error No such file or directory. I went through various posts online, which recommended to change permissions and adding usr/local/bin to the Path. I tried all that. The PATH also has usr/local/bin added to it by default. Not sure what's going wrong. Below is the docker image which will change permissions as well, echo the path and also run which tfswitch to identify the location of tfswitch. Everything seems to alright to me. Not sure what's wrong. Any idea what could be wrong?
FROM ruby:2.4.1-alpine AS Dummy_Image RUN apk add --update --no-cache curl RUN sh -c "$(curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh)" RUN echo "${PATH}" RUN which tfswitch RUN chmod 777 /usr/local/bin RUN ls -l /usr/local/bin RUN /usr/local/bin/tfswitch 0.12.24 I tried with RUN "/usr/local/bin/tfswitch 0.12.24", RUN "tfswitch 0.12.24" as well as RUN tfswitch 0.12.24, but doesn't work either way. Tried with chmod on the executable only as well.
tfswitch? You have a space between them. Also, you needchmod 777 /usr/local/bin/tfswitchrather than the directory.tfswitch. I tried putting the whole command under quotes as well. Doesn't work either way. Tried doing chmod on the executable instead of directory as well