Sign inSign up

hansohn/terraform-digitalocean

By hansohn

•Updated 4 days ago

Terraform DigitalOcean docker image with doctl and tooling for development and CI/CD

Image
0

3.0K

hansohn/terraform-digitalocean repository overview

⁠terraform-digitalocean-docker

Terraform DigitalOcean Docker image

⁠Table of Contents

⁠Description

Welcome to my Terraform DigitalOcean Docker repo. This image extends the terraform⁠ image with DigitalOcean-specific tooling, built with Terraform development and CI/CD in mind. It bundles the DigitalOcean CLI (doctl) on top of the base Terraform toolchain. Tool versions are pinned in the Dockerfile and kept current through dependency-update PRs; the image is rebuilt and published to Docker Hub weekly (Mondays) to pick up base-image security patches.

⁠What's Included

This image builds on hansohn/terraform⁠, which provides:

  • terraform⁠: Software tool that enables you to safely and predictably create, change, and improve infrastructure
  • terragrunt⁠: A thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules
  • terraform-docs⁠: Generate documentation from Terraform modules in various output formats
  • tflint⁠: A Pluggable Terraform Linter
  • trivy⁠: Security scanner for your Terraform code

On top of that base, this image adds:

  • doctl⁠: The official DigitalOcean command line interface (CLI), with bash completion pre-configured

⁠Prerequisites

  • Docker 20.10 or later
  • Docker Buildx with BuildKit (required for multi-platform builds and the build cache mounts the Dockerfile relies on)

⁠Quick Start

# Pull and run the latest version
docker pull hansohn/terraform-digitalocean:latest
docker run -it --rm hansohn/terraform-digitalocean:latest terraform version

# Run with your Terraform code mounted
docker run -it --rm -v $(pwd):/workspace -w /workspace hansohn/terraform-digitalocean:latest terraform plan

⁠Tags

Docker images are tagged based on the pinned version of Terraform they include (inherited from the base image). A single Terraform version is published at a time, and it receives the full set of tags below:

# tag formats (for a pinned Terraform version of e.g. 1.15.7)
hansohn/terraform-digitalocean:latest        the currently published release
hansohn/terraform-digitalocean:1             the 1.x.x line
hansohn/terraform-digitalocean:1.15          the 1.15.x line
hansohn/terraform-digitalocean:1.15.7        the exact version

For reproducibility, pin by digest (hansohn/terraform-digitalocean@sha256:...); every image ships provenance attestations and an SBOM bound to that digest.

⁠Platform Support

This image supports multiple platforms:

  • linux/amd64 (x86_64)
  • linux/arm64 (ARM64/Apple Silicon)

Docker will automatically pull the correct architecture for your system.

⁠Usage

Published images can be run using the following syntax:

# run latest published version
docker run -it --rm hansohn/terraform-digitalocean:latest /bin/bash

Local images can be built and run using the following syntax:

# build and run local image
make

Additionally, a Makefile has been included in this repo to assist with common development-related functions. I've included the following make targets for convenience:

Available targets:

  clean                               Clean everything
  dev                                 Initialize development environment
  docker/build                        Docker build image
  docker/check                        Check if Docker daemon is running
  docker/clean                        Docker clean build images
  docker/lint                         Lint Dockerfile
  docker/push                         Docker push image
  docker/run                          Docker run image
  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen

⁠Examples

⁠Initialize Terraform
docker run -it --rm -v $(pwd):/workspace -w /workspace \
  hansohn/terraform-digitalocean:latest terraform init
⁠Run the DigitalOcean CLI
docker run -it --rm -e DIGITALOCEAN_ACCESS_TOKEN \
  hansohn/terraform-digitalocean:latest doctl account get
⁠Generate Documentation
docker run -it --rm -v $(pwd):/docs -w /docs \
  hansohn/terraform-digitalocean:latest terraform-docs markdown . > README.md
⁠Run Security Scan
docker run -it --rm -v $(pwd):/src -w /src \
  hansohn/terraform-digitalocean:latest trivy config .

⁠Customization

⁠Utilities

Utility versions are pinned in the Dockerfile⁠ and kept current through automated dependency-update PRs. For a local build you can override any of them on the command line to target a specific version:

  • TERRAFORM_VERSION (selects the base hansohn/terraform image tag)
  • DOCTL_VERSION
# build against a specific doctl version
DOCTL_VERSION=1.163.0 make docker/build

Note: Builds require BuildKit (the default in modern Docker). The Dockerfile uses BuildKit cache mounts, so DOCKER_BUILDKIT=0 is not supported.

⁠Build & Refresh Schedule

Images are automatically:

  • Built and linted on every push, including main (multi-platform, without publishing)
  • Published when a version tag is pushed
  • Refreshed every Monday at 9am UTC, rebuilding main so merged dependency updates and base-image security patches reach Docker Hub — two hours after the hansohn/terraform base image refreshes, so this image picks it up the same morning

Pushes to main are built for verification but not published. Merged dependency updates ship on the next weekly refresh, or immediately if you cut a release tag.

⁠Security

  • Images include provenance attestations and SBOM (Software Bill of Materials)
  • The doctl release archive is checksum-verified at build time
  • Published images are scanned for vulnerabilities with Trivy
  • Security vulnerabilities? See our Security Policy⁠

This image is one of a family of infrastructure-tooling images built from the same Makefile, workflow and Renovate pattern. terraform-docker and cloudformation-docker each build directly from Debian; the four cloud-specific Terraform images layer on top of hansohn/terraform.

⁠Contributing

Contributions are welcome! Please see our Contributing Guide⁠ for details.

⁠License

This project is licensed under the terms specified in LICENSE⁠.

Tag summary

Content type

Image

Digest

sha256:d719619ed…

Size

223.2 MB

Last updated

4 days ago

docker pull hansohn/terraform-digitalocean