feat(tfenv): allow installing a custom Terraform version using tfenv#178
feat(tfenv): allow installing a custom Terraform version using tfenv#178FalcoSuessgott wants to merge 1 commit intopatrickchugh:mainfrom
Conversation
Signed-off-by: Tom Morelly <tom.morelly@clearroute.io>
patrickchugh
left a comment
There was a problem hiding this comment.
Thanks for the PR! I understand the problem — being locked to a single Terraform version in the Docker image is limiting. However, I have some concerns with the tfenv approach and would suggest a simpler alternative.
Concerns
-
Image bloat for all users — cloning the
tfenvrepo and addingbash(Alpine defaults tosh) increases the image size for everyone, even those who never use this feature. -
Runtime downloads are fragile —
tfenv installhits HashiCorp's servers on everydocker run. This breaks in air-gapped environments, adds startup latency, and is subject to network failures. -
Entrypoint wrapper — replacing the clean
ENTRYPOINT ["terravision"]with a shell script affects signal handling and adds a layer of indirection for debugging.
Suggested alternative
Since Terraform is a single static binary, a build-time ARG achieves the same goal without any runtime dependencies:
ARG TERRAFORM_VERSION=1.10.5
RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \
&& unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin/ \
&& rm terraform_${TERRAFORM_VERSION}_linux_amd64.zipUsage:
docker build --build-arg TERRAFORM_VERSION=1.13.0 -t terravision .This keeps the image lean, works offline after build, and doesn't require tfenv, bash, or an entrypoint script.
Would you be open to reworking the PR with this approach?
Image size when building I think that's a good trade-off given the fact that now users can specify their own TF version.
Users can specify a local HTTP server to fetch the binaries from by simply specifying TFENV_REVERSE_REMOTE allowing it to be used in air gapped environments
I don't understand how overwriting the
The point of this PR is to allow users specify their own TF version without having to build, publish & maintain a custom container image of |
Currently
terravisionhardodes the TF version in its Dockerfile. This makes it difficult to useterravisionwith TF setups that differ from the upstream image versions.This PR adds tfenv to the Dockerfile and invokes
tfenvonly whenTFENV_TERRAFORM_VERSIONhas been specified, which then downloads and installs the specified TF version before invokingterravision:Example: specifying no custom Terraform version:
Example: specifying a custom Terraform version: