cytopia/terraform-docs

By cytopia

Updated 9 months ago

Tiny Docker image for terraform-docs in multiple versions to be used for CI and other automations

Image
10

1M+

cytopia/terraform-docs repository overview

Docker image for terraform-docs

Tag License

lint build nightly

View Dockerfiles on GitHub.

Available Architectures: amd64, i386, arm64, arm/v7, arm/v6

Tiny Alpine-based multistage-build dockerized version of terraform-docs[1], which additionally implements terraform-docs-replace allowing you to automatically and safely replace the terraform-docs generated output infile. Furthermore this implementation is also Terraform >= 0.12 ready[2]. See Generic Usage for more details. The image is built nightly against multiple stable versions and pushed to Dockerhub.

:whale: Available Docker image versions

Docker

Rolling releaess

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker TagGit RefTerraform DocsAvailable Architectures
latestmasterlatestamd64, i386, arm64, arm/v7, arm/v6
0.16.0master0.16.0amd64, i386, arm64, arm/v7, arm/v6
0.15.0master0.15.0amd64, i386, arm64, arm/v7, arm/v6
0.14.1master0.14.1amd64, i386, arm64, arm/v7, arm/v6
0.14.0master0.14.0amd64, i386, arm64, arm/v7, arm/v6
0.13.0master0.13.0amd64, i386, arm64, arm/v7, arm/v6
0.12.1master0.12.1amd64, i386, arm64, arm/v7, arm/v6
0.12.0master0.12.0amd64, i386, arm64, arm/v7, arm/v6
0.11.2master0.11.2amd64
0.11.1master0.11.1amd64
0.11.0master0.11.0amd64
0.10.1master0.10.1amd64
0.10.0master0.10.0amd64
0.9.1master0.9.1amd64
0.9.0master0.9.0amd64
0.8.2master0.8.2amd64
0.8.1master0.8.1amd64
0.8.0master0.8.0amd64
0.7.0master0.7.0amd64
0.6.0master0.6.0amd64
0.5.0master0.5.0amd64
0.4.5master0.4.5amd64
0.4.0master0.4.0amd64
0.3.0master0.3.0amd64
0.2.0master0.2.0amd64
0.1.1master0.1.1amd64
0.1.0master0.1.0amd64
Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker TagGit RefTerraform DocsAvailable Architectures
latest-0.32tag: 0.32latestamd64, i386, arm64, arm/v7, arm/v6
0.16.0-0.32tag: 0.320.16.0amd64, i386, arm64, arm/v7, arm/v6
0.15.0-0.32tag: 0.320.15.0amd64, i386, arm64, arm/v7, arm/v6
0.14.1-0.32tag: 0.320.14.1amd64, i386, arm64, arm/v7, arm/v6
0.14.0-0.32tag: 0.320.14.0amd64, i386, arm64, arm/v7, arm/v6
0.13.0-0.32tag: 0.320.13.0amd64, i386, arm64, arm/v7, arm/v6
0.12.1-0.32tag: 0.320.12.1amd64, i386, arm64, arm/v7, arm/v6
0.12.0-0.32tag: 0.320.12.0amd64, i386, arm64, arm/v7, arm/v6
0.11.2-0.32tag: 0.320.11.2amd64
0.11.1-0.32tag: 0.320.11.1amd64
0.11.0-0.32tag: 0.320.11.0amd64
0.10.1-0.32tag: 0.320.10.1amd64
0.10.0-0.32tag: 0.320.10.0amd64
0.9.1-0.32tag: 0.320.9.1amd64
0.9.0-0.32tag: 0.320.9.0amd64
0.8.2-0.32tag: 0.320.8.2amd64
0.8.1-0.32tag: 0.320.8.1amd64
0.8.0-0.32tag: 0.320.8.0amd64
0.7.0-0.32tag: 0.320.7.0amd64
0.6.0-0.32tag: 0.320.6.0amd64
0.5.0-0.32tag: 0.320.5.0amd64
0.4.5-0.32tag: 0.320.4.5amd64
0.4.0-0.32tag: 0.320.4.0amd64
0.3.0-0.32tag: 0.320.3.0amd64
0.2.0-0.32tag: 0.320.2.0amd64
0.1.1-0.32tag: 0.320.1.1amd64
0.1.0-0.32tag: 0.320.1.0amd64

:capital_abcd: Environment variables

The following Docker environment variables are available. These will only need to be used when using terraform-docs-replace or terraform-docs-replace-012.

VariableDefaultRequiredComment
DELIM_START<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->NoThe starting delimiter in the file in where you want to replace the terraform-docs output.
DELIM_CLOSE<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->NoThe ending delimiter in the file in where you want to replace the terraform-docs output.

:open_file_folder: Docker mounts

The working directory inside the Docker container is /data/ and should be mounted locally to where your Terraform module is located.

:computer: Usage

Generic
Usage: cytopia/terraform-docs terraform-docs <ARGS> .
       cytopia/terraform-docs terraform-docs-012 <ARGS> .

       cytopia/terraform-docs terraform-docs-replace <ARGS> <PATH-TO-FILE>
       cytopia/terraform-docs terraform-docs-replace-012 <ARGS> <PATH-TO-FILE>


terraform-docs              Output as expected from terraform-docs
terraform-docs-012          Same as above, but used for Terraform >= 0.12 modules

terraform-docs-replace      Replaces directly inside README.md, if DELIM_START and DELIM_CLOSE are found.
terraform-docs-replace-012  Same as above, but used for Terraform >= 0.12 modules

<ARGS>                      All arguments terraform-docs command can use.
<PATH-TO-FILE>              File in where to auto-replace terraform-docs block.
Output to stdout

Create markdown output and sent to stdout:

# [Terraform < 0.12]
docker run --rm \
  -v $(pwd):/data \
  cytopia/terraform-docs \
  terraform-docs --sort-by-required md .

# [Terraform >= 0.12]
docker run --rm \
  -v $(pwd):/data \
  cytopia/terraform-docs \
  terraform-docs-012 --sort-by-required md .
Store in file

Create README.md with terraform-docs output:

# [Terraform < 0.12]
docker run --rm \
  -v $(pwd):/data \
  cytopia/terraform-docs \
  terraform-docs --sort-by-required md . > README.md

# [Terraform >= 0.12]
docker run --rm \
  -v $(pwd):/data \
  cytopia/terraform-docs \
  terraform-docs-012 --sort-by-required md . > README.md
Replace in README.md

Replace current terraform-docs blocks in README.md with current one in order to automatically keep it up to date. For this to work, the terraform-docs information must be wrapped with the following delimiter by default:

README.md:

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs
...
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
# [Terraform < 0.12]
# Path to README.md must be specified as last command.
# Note that the command changes from terraform-docs to terraform-docs-replace
docker run --rm \
  -v $(pwd):/data \
  cytopia/terraform-docs \
  terraform-docs-replace --sort-by-required md README.md

# [Terraform >= 0.12]
# Path to README.md must be specified as last command.
# Note that the command changes from terraform-docs to terraform-docs-replace
docker run --rm \
  -v $(pwd):/data \
  cytopia/terraform-docs \
  terraform-docs-replace-012 --sort-by-required md README.md
Replace in INFO.md with different delimiter

You are able to use different delimiter. Let's imagine the following delimiter:

INFO.md:

<!-- TFDOC_START -->
## Inputs
...
<!-- TFDOC_END -->
# [Terraform < 0.12]
# Path to INFO.md must be specified as last command.
# Note that the command changes from terraform-docs to terraform-docs-replace
docker run --rm \
  -v $(pwd):/data \
  -e DELIM_START='<!-- TFDOC_START -->' \
  -e DELIM_CLOSE='<!-- TFDOC_END -->' \
  cytopia/terraform-docs \
  terraform-docs-replace --sort-by-required md INFO.md

# [Terraform >= 0.12]
# Path to INFO.md must be specified as last command.
# Note that the command changes from terraform-docs to terraform-docs-replace
docker run --rm \
  -v $(pwd):/data \
  -e DELIM_START='<!-- TFDOC_START -->' \
  -e DELIM_CLOSE='<!-- TFDOC_END -->' \
  cytopia/terraform-docs \
  terraform-docs-replace-012 --sort-by-required md INFO.md

:information_source: Example projects

Find below some example projects how this Docker image is used in CI to verify if the README.md has been updated with the latest changes generated from terraform-docs:

Docker images

Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite linter below for reproducible local or remote CI tests:

GitHubDockerHubTypeDescription
awesome-ciaci-hub-imgBasicTools for git, file and static source code analysis
file-lintflint-hub-imgBasicBaisc source code analysis
linkchecklinkcheck-hub-imgBasicSearch for URLs in files and validate their HTTP status code
ansibleansible-hub-imgAnsibleMultiple versions and flavours of Ansible
ansible-lintalint-hub-imgAnsibleLint Ansible
gofmtgfmt-hub-imgGoFormat Go source code [1]
goimportsgimp-hub-imgGoFormat Go source code [1]
golintglint-hub-imgGoLint Go code
eslintelint-hub-imgJavascriptLint Javascript code
jsonlintjlint-hub-imgJSONLint JSON files [1]
kubevalkubeval-hub-imgK8sLint Kubernetes files
checkmakecm-hub-imgMakeLint Makefiles
phpcbfpcbf-hub-imgPHPPHP Code Beautifier and Fixer
phpcspcs-hub-imgPHPPHP Code Sniffer
phplintplint-hub-imgPHPPHP Code Linter [1]
php-cs-fixerpcsf-hub-imgPHPPHP Coding Standards Fixer
banditbandit-hub-imgPythonA security linter from PyCQA
blackblack-hub-imgPythonThe uncompromising Python code formatter
mypymypy-hub-imgPythonStatic source code analysis
pycodestylepycs-hub-imgPythonPython style guide checker
pydocstylepyds-hub-imgPythonPython docstyle checker
pylintpylint-hub-imgPythonPython source code, bug and quality checker
terraform-docstfdocs-hub-imgTerraformTerraform doc generator (TF 0.12 ready) [1]
terragrunttg-hub-imgTerraformTerragrunt and Terraform
terragrunt-fmttgfmt-hub-imgTerraformterraform fmt for Terragrunt files [1]
yamlfmtyfmt-hub-imgYamlFormat Yaml files [1]
yamllintylint-hub-imgYamlLint Yaml files

[1] Uses a shell wrapper to add enhanced functionality not available by original project.

Makefiles

Visit cytopia/makefiles for dependency-less, seamless project integration and minimum required best-practice code linting for CI. The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else.

:page_facing_up: License

MIT License

Copyright (c) 2019 cytopia

Tag summary

Content type

Image

Digest

sha256:ae03f8d4f

Size

13.6 MB

Last updated

9 months ago

docker pull cytopia/terraform-docs:0.13.0-0.37