Skip to content

fix: install terraform in base Docker image #6263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 7, 2023
Merged

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Feb 17, 2023

This PR adds terraform to all Coder base images. It's a required dependency so it makes sense to bundle it with the image.

Still TODO: providers and plugins
Not bundling providers at this time.

Fixes #6258

@johnstcn johnstcn requested a review from kylecarbs February 17, 2023 17:44
@johnstcn johnstcn self-assigned this Feb 17, 2023
@coadler
Copy link
Contributor

coadler commented Feb 17, 2023

I think there's a weird interaction with the Terraform downloader such that it will still try to download Terraform when it's installed but the wrong version. Are we able to be sure those versions stay in sync?

@johnstcn
Copy link
Member Author

I think there's a weird interaction with the Terraform downloader such that it will still try to download Terraform when it's installed but the wrong version. Are we able to be sure those versions stay in sync?

We could specify with our apk add version == the Terraform version we try to fetch? How picky is it?

@bpmct
Copy link
Member

bpmct commented Feb 17, 2023

TerraformVersion = version.Must(version.NewVersion("1.3.4"))
minTerraformVersion = version.Must(version.NewVersion("1.1.0"))
maxTerraformVersion = version.Must(version.NewVersion("1.3.4"))

@johnstcn
Copy link
Member Author

johnstcn commented Feb 17, 2023

TerraformVersion = version.Must(version.NewVersion("1.3.4"))
minTerraformVersion = version.Must(version.NewVersion("1.1.0"))
maxTerraformVersion = version.Must(version.NewVersion("1.3.4"))

Seems like the simplest option is to manually specify the version in apk but add comments both in the base image and in the above file to ensure these are kept in sync. Worst case here is that the image builds will fail, but that's easier to troubleshoot than random crashlooping coderd pods.

RUN mkdir -p /opt/terraform/plugins/registry.terraform.io
# Add config for local terraform
ADD files/terraform-config.tfrc /opt/terraform/config.tfrc
ARG CODER_PROVIDER_VERSION=0.6.12
Copy link
Member

@bpmct bpmct Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These versions (for Coder and the other providers) can also get quickly out of sync from what we hardcode in our example templates too, which will cause Terraform to still fail

Maybe we stick to just embedding Terraform and make the TRFC configurable via a code server flag or something in an additional PR? Then, an external PVC can be mounted or a network mirror can be specified #6189

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that sounds like a better option. Baking in all of the Terraform providers we use in examples/templates would inflate our base image by 199MB.

Copy link
Member

@bpmct bpmct left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to merge this, can you change our offline docs?

@johnstcn
Copy link
Member Author

johnstcn commented Mar 6, 2023

If you are going to merge this, can you change our offline docs?

Yep

@johnstcn johnstcn requested a review from bpmct March 6, 2023 17:40
@johnstcn johnstcn merged commit 248c53d into main Mar 7, 2023
@johnstcn johnstcn deleted the cj/docker-add-terraform branch March 7, 2023 13:52
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: in air-gapped kubernetes cluster, coderd deployment crashloops
4 participants