Skip to content

Commit

Permalink
Merge pull request #73 from theohbrothers/enhancement/add-terraform-1…
Browse files Browse the repository at this point in the history
….8.0-variants

Enhancement: Add terraform 1.8.0 variants
  • Loading branch information
theohbrothersbot authored Apr 12, 2024
2 parents 439be1e + 2708114 commit e9ef92f
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 2 deletions.
258 changes: 257 additions & 1 deletion .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,260 @@ jobs:
run: |
git diff --exit-code
build-1-8-0:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
docker info
docker version
# See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-1.8.0-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-1.8.0-
${{ runner.os }}-buildx-
- name: Login to Docker Hub registry
# Run on master and tags
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}

# This step generates the docker tags
- name: Prepare
id: prep-1-8-0
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="1.8.0"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: 1.8.0 - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: variants/1.8.0
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: false
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 1.8.0 - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
context: variants/1.8.0
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 1.8.0 - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: variants/1.8.0
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0.outputs.REF_SHA_VARIANT }}
${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-1-8-0-jq-sops-ssh
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="1.8.0-jq-sops-ssh"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: 1.8.0-jq-sops-ssh - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: variants/1.8.0-jq-sops-ssh
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: false
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 1.8.0-jq-sops-ssh - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
context: variants/1.8.0-jq-sops-ssh
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 1.8.0-jq-sops-ssh - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: variants/1.8.0-jq-sops-ssh
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-sops-ssh.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-1-8-0-jq-libvirt-sops-ssh
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="1.8.0-jq-libvirt-sops-ssh"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: 1.8.0-jq-libvirt-sops-ssh - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: variants/1.8.0-jq-libvirt-sops-ssh
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: false
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 1.8.0-jq-libvirt-sops-ssh - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
context: variants/1.8.0-jq-libvirt-sops-ssh
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 1.8.0-jq-libvirt-sops-ssh - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: variants/1.8.0-jq-libvirt-sops-ssh
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: |
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-8-0-jq-libvirt-sops-ssh.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-1-7-5:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -141,7 +395,6 @@ jobs:
${{ github.repository }}:${{ steps.prep-1-7-5.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-1-7-5.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-1-7-5.outputs.REF_SHA_VARIANT }}
${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

Expand Down Expand Up @@ -4084,6 +4337,7 @@ jobs:
update-draft-release:
needs:
- build-1-8-0
- build-1-7-5
- build-1-6-6
- build-1-5-7
Expand Down Expand Up @@ -4113,6 +4367,7 @@ jobs:

publish-draft-release:
needs:
- build-1-8-0
- build-1-7-5
- build-1-6-6
- build-1-5-7
Expand Down Expand Up @@ -4144,6 +4399,7 @@ jobs:

update-dockerhub-description:
needs:
- build-1-8-0
- build-1-7-5
- build-1-6-6
- build-1-5-7
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ The base image is `alpine`. The image is not the closed-source [`hashicorp/terra

| Tag | Dockerfile Build Context |
|:-------:|:---------:|
| `:1.7.5`, `:latest` | [View](variants/1.7.5) |
| `:1.8.0`, `:latest` | [View](variants/1.8.0) |
| `:1.8.0-jq-sops-ssh` | [View](variants/1.8.0-jq-sops-ssh) |
| `:1.8.0-jq-libvirt-sops-ssh` | [View](variants/1.8.0-jq-libvirt-sops-ssh) |
| `:1.7.5` | [View](variants/1.7.5) |
| `:1.7.5-jq-sops-ssh` | [View](variants/1.7.5-jq-sops-ssh) |
| `:1.7.5-jq-libvirt-sops-ssh` | [View](variants/1.7.5-jq-libvirt-sops-ssh) |
| `:1.6.6` | [View](variants/1.6.6) |
Expand Down
1 change: 1 addition & 0 deletions generate/definitions/versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"terraform": {
"versions": [
"1.8.0",
"1.7.5",
"1.6.6",
"1.5.7",
Expand Down
63 changes: 63 additions & 0 deletions variants/1.8.0-jq-libvirt-sops-ssh/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM alpine:3.17
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"
# Install terraform
RUN set -eux; \
TERRAFORM_VERSION=1.8.0; \
case "$( uname -m )" in \
'x86') \
URL="https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_386.zip"; \
SHA256=858e2ca2d38ce3644607af68eb5184a91493feecf82346deb386fd6cfbfad785; \
;; \
'x86_64') \
URL="https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_amd64.zip"; \
SHA256=dcc4670379a22213e72faa6cb709b3391e7e54967e40288ecf591e2b83cfd39e; \
;; \
'armhf') \
URL="https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_arm.zip"; \
SHA256=25ecd729af5cf2774625521833cfd17ad92cd418f2342732b08bbcd1107026ed; \
;; \
'armv7l') \
URL="https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_arm.zip"; \
SHA256=25ecd729af5cf2774625521833cfd17ad92cd418f2342732b08bbcd1107026ed; \
;; \
'aarch64') \
URL="https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_arm64.zip"; \
SHA256=47cbde7184ce260160ff0355065d454ffa5628a2259ba325736dbcf740351193; \
;; \
*) \
echo "Architecture not supported"; \
exit 1; \
;; \
esac; \
FILE=terraform.zip; \
wget -q "$URL" -O "$FILE"; \
echo "$SHA256 $FILE" | sha256sum -c -; \
unzip "$FILE" terraform; \
mkdir -pv /usr/local/bin; \
mv -v terraform /usr/local/bin/terraform; \
chmod +x /usr/local/bin/terraform; \
CHECKPOINT_DISABLE=1 terraform version; \
:

RUN apk add --no-cache ca-certificates

RUN apk add --no-cache jq

RUN apk add --no-cache libvirt-client

RUN set -eux; \
wget -qO- https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux > /usr/local/bin/sops; \
chmod +x /usr/local/bin/sops; \
sha256sum /usr/local/bin/sops | grep '^185348fd77fc160d5bdf3cd20ecbc796163504fd3df196d7cb29000773657b74 '; \
sops --version

RUN apk add --no-cache gnupg

RUN apk add --no-cache openssh-client sshpass

# Disable telemetry. See: https://developer.hashicorp.com/terraform/cli/commands#upgrade-and-security-bulletin-checks
ENV CHECKPOINT_DISABLE=1

CMD [ "terraform" ]
Loading

0 comments on commit e9ef92f

Please sign in to comment.