Skip to content
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

build: use opentofu binary in harness terraform image #217

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .github/workflows/publish-harness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,36 @@ jobs:
runs-on: ubuntu-20.04
needs: [publish-harness-base]
env:
TERRAFORM_VERSION: 1.8.2
TOFU_VERESION: 1.7.2
strategy:
matrix:
versions:
- full: 1.8.2
tag: 1.8.2
- full: 1.8.2
- tofu: 1.7.2
terraform: 1.8.2
tag: "1.8"
- full: 1.7.5
- tofu: 1.7.1
terraform: 1.7.5
tag: '1.7'
- full: 1.6.6
- tofu: 1.6.2
terraform: 1.6.6
tag: '1.6'
- full: 1.5.7
- tofu: 1.6.2
terraform: 1.5.7
tag: '1.5'
- full: 1.4.7
- tofu: 1.6.2
terraform: 1.4.7
tag: '1.4'
- full: 1.3.10
- tofu: 1.6.2
terraform: 1.3.10
tag: '1.3'
- full: 1.2.9
- tofu: 1.6.2
terraform: 1.2.9
tag: '1.2'
- full: 1.1.9
- tofu: 1.6.2
terraform: 1.1.9
tag: '1.1'
- full: 1.0.11
- tofu: 1.6.2
Copy link
Member

Choose a reason for hiding this comment

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

are these versions actually aligned? Looks like the tofu version is always 1.6.2?

Copy link
Contributor Author

@seemywingz seemywingz Jun 17, 2024

Choose a reason for hiding this comment

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

yes, according to OpenTofu Migration Docs

When migrating from Terraform 1.5.x or lower, please migrate to OpenTofu 1.6.2 first

But with a caveat:

This migration guide is only valid for Terraform 1.5.7. If you are on a Terraform version below 1.5.7, please upgrade to at least Terraform version 1.5.7 before proceeding with the migration by following the Terraform upgrade guide. If you are on a higher Terraform version, please select the appropriate migration guide for your Terraform version.

terraform: 1.0.11
tag: '1.0'
permissions:
contents: write
Expand Down Expand Up @@ -161,15 +168,16 @@ jobs:
uses: docker/build-push-action@v5
with:
context: "."
file: "./dockerfiles/harness/terraform.Dockerfile"
file: ${{ matrix.versions.terraform >= '1.5.7' && './dockerfiles/harness/opentofu.Dockerfile' || './dockerfiles/harness/terraform.Dockerfile' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
TERRAFORM_IMAGE_TAG=${{ matrix.versions.full }}
TOFU_IMAGE_TAG=${{ matrix.versions.tofu }}
TERRAFORM_IMAGE_TAG=${{ matrix.versions.terraform }}
HARNESS_BASE_IMAGE_REPO=ghcr.io/pluralsh/stackrun-harness-base
HARNESS_BASE_IMAGE_TAG=${{ needs.publish-harness-base.outputs.version }}

Expand Down
14 changes: 14 additions & 0 deletions dockerfiles/harness/opentofu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG TOFU_IMAGE_TAG=1.7.1
Fixed Show fixed Hide fixed

Check notice

Code scanning / Trivy

No HEALTHCHECK defined Low

Artifact: dockerfiles/harness/opentofu.Dockerfile
Type: dockerfile
Vulnerability DS026
Severity: LOW
Message: Add HEALTHCHECK instruction in your Dockerfile
Link: DS026
ARG TOFU_IMAGE=ghcr.io/opentofu/opentofu:$TOFU_IMAGE_TAG

ARG HARNESS_BASE_IMAGE_TAG=latest
ARG HARNESS_BASE_IMAGE_REPO=harness-base
ARG HARNESS_BASE_IMAGE=$HARNESS_BASE_IMAGE_REPO:$HARNESS_BASE_IMAGE_TAG

FROM $TOFU_IMAGE as tofu
Fixed Show fixed Hide fixed
FROM $HARNESS_BASE_IMAGE as final
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

COPY --from=tofu /usr/local/bin/tofu /bin/terraform

# Switch to the non-root user
USER 65532:65532
Loading