diff --git a/docs/install/offline.md b/docs/install/offline.md index 94e856a364e03..e0bff646ef4ba 100644 --- a/docs/install/offline.md +++ b/docs/install/offline.md @@ -6,11 +6,13 @@ Coder can run in offline / air-gapped environments. First, build and push a container image extending our official image with the following: -- Terraform [(supported versions)](https://github.com/coder/coder/blob/main/provisioner/terraform/install.go#L23-L24) - CLI config (.tfrc) for Terraform referring to [external mirror](https://www.terraform.io/cli/config/config-file#explicit-installation-method-configuration) - [Terraform Providers](https://registry.terraform.io) for templates - These could also be specified via a volume mount (Docker) or [network mirror](https://www.terraform.io/internals/provider-network-mirror-protocol). See below for details. +> Note: Coder includes the latest [supported version](https://github.com/coder/coder/blob/main/provisioner/terraform/install.go#L23-L24) of Terraform in the official Docker images. +> If you need to bundle a different version of terraform, you can do so by customizing the image. + Here's an example: ```Dockerfile @@ -24,13 +26,16 @@ RUN apk add curl unzip # Create directory for the Terraform CLI (and assets) RUN mkdir -p /opt/terraform -# In order to run Coder airgapped or within private networks, -# Terraform has to be bundled into the image in PATH or /opt. -# +# Terraform is already included in the official Coder image. +# See https://github.com/coder/coder/blob/main/scripts/Dockerfile.base#L15 +# If you need to install a different version of Terraform, you can do so here. +# The below step is optional if you wish to keep the existing version. # See https://github.com/coder/coder/blob/main/provisioner/terraform/install.go#L23-L24 # for supported Terraform versions. ARG TERRAFORM_VERSION=1.3.0 -RUN curl -LOs https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \ +RUN apk update && \ + apk del terraform && \ + curl -LOs https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \ && unzip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip \ && mv terraform /opt/terraform \ && rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip diff --git a/provisioner/terraform/install.go b/provisioner/terraform/install.go index 08b2796d4753a..ddaf4024731d3 100644 --- a/provisioner/terraform/install.go +++ b/provisioner/terraform/install.go @@ -18,6 +18,7 @@ import ( var ( // TerraformVersion is the version of Terraform used internally // when Terraform is not available on the system. + // NOTE: Keep this in sync with the version in scripts/Dockerfile.base. TerraformVersion = version.Must(version.NewVersion("1.3.4")) minTerraformVersion = version.Must(version.NewVersion("1.1.0")) diff --git a/scripts/Dockerfile.base b/scripts/Dockerfile.base index 8d926fe8eac55..9e0de834ae0b2 100644 --- a/scripts/Dockerfile.base +++ b/scripts/Dockerfile.base @@ -4,12 +4,15 @@ FROM alpine:latest # We use a single RUN command to reduce the number of layers in the image. +# NOTE: Keep the Terraform version in sync with minTerraformVersion and +# maxTerraformVersion in provisioner/terraform/install.go. RUN apk add --no-cache \ curl \ wget \ bash \ git \ - openssh-client && \ + openssh-client \ + terraform=1.3.4-r2 && \ addgroup \ -g 1000 \ coder && \