All #awesome-ci Docker images
ansible • ansible-lint • awesome-ci • black • checkmake • eslint • file-lint • gofmt • goimports • golint • jsonlint • linkcheck • mypy • phpcbf • phpcs • phplint • php-cs-fixer • pycodestyle • pydocstyle • pylint • terraform-docs • terragrunt • terragrunt-fmt • yamlfmt • yamllint
All #awesome-ci Makefiles
Visit cytopia/makefiles for seamless project integration, minimum required best-practice code linting and CI.
View Dockerfile on GitHub.
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.
- [1] Official project: https://github.com/terraform-docs/terraform-docs
- [2] Based on an awk script by cloudposse/build-harness
The following Docker image tags are rolling releases and built and updated nightly. This means any
scripts from this repository which enhance the original terraform-docs
are always available at
their latest state (from this repository's master branch) and might cause backwards
incompatibilities with how you use it (although it's very unlikely that backwards incompatible
changes will be introduced).
Docker tag | Build from docker-terraform-docs | Build from terraform-docs |
---|---|---|
latest |
Branch: master | Branch: master |
0.10.1 |
Branch: master | Tag: v0.10.1 |
0.10.0 |
Branch: master | Tag: v0.10.0 |
0.9.1 |
Branch: master | Tag: v0.9.1 |
0.9.0 |
Branch: master | Tag: v0.9.0 |
0.8.2 |
Branch: master | Tag: v0.8.2 |
0.8.1 |
Branch: master | Tag: v0.8.1 |
0.8.0 |
Branch: master | Tag: v0.8.0 |
0.8.0-rc.3 |
Branch: master | Tag: v0.8.0-rc.3 |
0.8.0-rc.2 |
Branch: master | Tag: v0.8.0-rc.2 |
0.8.0-rc.1 |
Branch: master | Tag: v0.8.0-rc.1 |
0.7.0 |
Branch: master | Tag: v0.7.0 |
0.6.0 |
Branch: master | Tag: v0.6.0 |
0.5.0 |
Branch: master | Tag: v0.5.0 |
0.4.5 |
Branch: master | Tag: v0.4.5 |
0.4.0 |
Branch: master | Tag: v0.4.0 |
0.3.0 |
Branch: master | Tag: v0.3.0 |
0.2.0 |
Branch: master | Tag: v0.2.0 |
0.1.1 |
Branch: master | Tag: v0.1.1 |
0.1.0 |
Branch: master | Tag: v0.1.0 |
If you want to ensure to have reproducible Terraform doc generation you should use a git tag from this repository. Tags are incremented for each new version, but never updated itself. This means you will have to take care yourself and update your CI tools every time a new tag is being released.
Docker tag | Build from docker-terraform-docs | Build from terraform-docs |
---|---|---|
latest-<tag> |
Tag: <tag> |
Branch: master |
0.10.1-<tag> |
Tag: <tag> |
Tag: v0.10.1 |
0.10.0-<tag> |
Tag: <tag> |
Tag: v0.10.0 |
0.9.1-<tag> |
Tag: <tag> |
Tag: v0.9.1 |
0.9.0-<tag> |
Tag: <tag> |
Tag: v0.9.0 |
0.8.2-<tag> |
Tag: <tag> |
Tag: v0.8.2 |
0.8.1-<tag> |
Tag: <tag> |
Tag: v0.8.1 |
0.8.0-<tag> |
Tag: <tag> |
Tag: v0.8.0 |
0.8.0-rc.3-<tag> |
Tag: <tag> |
Tag: v0.8.0-rc.3 |
0.8.0-rc.2-<tag> |
Tag: <tag> |
Tag: v0.8.0-rc.2 |
0.8.0-rc.1-<tag> |
Tag: <tag> |
Tag: v0.8.0-rc.1 |
0.7.0-<tag> |
Tag: <tag> |
Tag: v0.7.0 |
0.6.0-<tag> |
Tag: <tag> |
Tag: v0.6.0 |
0.5.0-<tag> |
Tag: <tag> |
Tag: v0.5.0 |
0.4.5-<tag> |
Tag: <tag> |
Tag: v0.4.5 |
0.4.0-<tag> |
Tag: <tag> |
Tag: v0.4.0 |
0.3.0-<tag> |
Tag: <tag> |
Tag: v0.3.0 |
0.2.0-<tag> |
Tag: <tag> |
Tag: v0.2.0 |
0.1.1-<tag> |
Tag: <tag> |
Tag: v0.1.1 |
0.1.0-<tag> |
Tag: <tag> |
Tag: v0.1.0 |
Where <tag>
refers to the chosen git tag from this repository.
The following Docker environment variables are available. These will only need to be used when
using terraform-docs-replace
or terraform-docs-replace-012
.
Variable | Default | Required | Comment |
---|---|---|---|
DELIM_START | <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
No | The starting delimiter in the file in where you want to replace the terraform-docs output. |
DELIM_CLOSE | <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
No | The ending delimiter in the file in where you want to replace the terraform-docs output. |
The working directory inside the Docker container is /data/
and should be mounted locally to
where your Terraform module is located.
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.
Create markdown output and sent to stdout:
# [Terraform < 0.12]
docker run --rm \
-v $(pwd):/data \
cytopia/terraform-docs \
terraform-docs --sort-inputs-by-required --with-aggregate-type-defaults md .
# [Terraform >= 0.12]
docker run --rm \
-v $(pwd):/data \
cytopia/terraform-docs \
terraform-docs-012 --sort-inputs-by-required --with-aggregate-type-defaults md .
Create README.md with terraform-docs
output:
# [Terraform < 0.12]
docker run --rm \
-v $(pwd):/data \
cytopia/terraform-docs \
terraform-docs --sort-inputs-by-required --with-aggregate-type-defaults md . > README.md
# [Terraform >= 0.12]
docker run --rm \
-v $(pwd):/data \
cytopia/terraform-docs \
terraform-docs-012 --sort-inputs-by-required --with-aggregate-type-defaults md . > 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-inputs-by-required --with-aggregate-type-defaults 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-inputs-by-required --with-aggregate-type-defaults md README.md
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-inputs-by-required --with-aggregate-type-defaults 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-inputs-by-required --with-aggregate-type-defaults md INFO.md
You can add the following Makefile to your project for easy generation of terraform-docs output in a Terraform module. It takes into consideration the Main module, sub-modules and examples.
ifneq (,)
.error This Makefile requires GNU Make.
endif
.PHONY: gen _gen-main _gen-examples _gen-modules _update-tf-docs
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TF_EXAMPLES = $(sort $(dir $(wildcard $(CURRENT_DIR)examples/*/)))
TF_MODULES = $(sort $(dir $(wildcard $(CURRENT_DIR)modules/*/)))
TF_DOCS_VERSION = 0.6.0
# Adjust your delimiter here or overwrite via make arguments
DELIM_START = <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
DELIM_CLOSE = <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
gen: _update-tf-docs
@echo "################################################################################"
@echo "# Terraform-docs generate"
@echo "################################################################################"
@$(MAKE) --no-print-directory _gen-main
@$(MAKE) --no-print-directory _gen-examples
@$(MAKE) --no-print-directory _gen-modules
_gen-main:
@echo "------------------------------------------------------------"
@echo "# Main module"
@echo "------------------------------------------------------------"
@if docker run --rm \
-v $(CURRENT_DIR):/data \
-e DELIM_START='$(DELIM_START)' \
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
terraform-docs-replace --sort-inputs-by-required --with-aggregate-type-defaults md README.md; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi
_gen-examples:
@$(foreach example,\
$(TF_EXAMPLES),\
DOCKER_PATH="examples/$(notdir $(patsubst %/,%,$(example)))"; \
echo "------------------------------------------------------------"; \
echo "# $${DOCKER_PATH}"; \
echo "------------------------------------------------------------"; \
if docker run --rm \
-v $(CURRENT_DIR):/data \
-e DELIM_START='$(DELIM_START)' \
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
terraform-docs-replace --sort-inputs-by-required --with-aggregate-type-defaults md $${DOCKER_PATH}/README.md; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi; \
)
_gen-modules:
@$(foreach module,\
$(TF_MODULES),\
DOCKER_PATH="modules/$(notdir $(patsubst %/,%,$(module)))"; \
echo "------------------------------------------------------------"; \
echo "# $${DOCKER_PATH}"; \
echo "------------------------------------------------------------"; \
if docker run --rm \
-v $(CURRENT_DIR):/data \
-e DELIM_START='$(DELIM_START)' \
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
terraform-docs-replace --sort-inputs-by-required --with-aggregate-type-defaults md $${DOCKER_PATH}/README.md; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi; \
)
_update-tf-docs:
docker pull cytopia/terraform-docs:$(TF_DOCS_VERSION)
With the above Makefile in place, you can easily add a Travis CI rule to ensure the terraform-docs output is always up-to-date and will fail otherwise (due to git changes):
---
sudo: required
language: minimal
services:
- docker
script:
- make gen
- git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
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
:
- https://github.com/cytopia/terraform-aws-rds/blob/master/Makefile
- https://github.com/Flaconi/terraform-aws-microservice/blob/master/Makefile
Related #awesome-ci projects
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:
GitHub | DockerHub | Type | Description |
---|---|---|---|
awesome-ci | Basic | Tools for git, file and static source code analysis | |
file-lint | Basic | Baisc source code analysis | |
linkcheck | Basic | Search for URLs in files and validate their HTTP status code | |
ansible | Ansible | Multiple versions and flavours of Ansible | |
ansible-lint | Ansible | Lint Ansible | |
gofmt | Go | Format Go source code [1] | |
goimports | Go | Format Go source code [1] | |
golint | Go | Lint Go code | |
eslint | Javascript | Lint Javascript code | |
jsonlint | JSON | Lint JSON files [1] | |
checkmake | Make | Lint Makefiles | |
phpcbf | PHP | PHP Code Beautifier and Fixer | |
phpcs | PHP | PHP Code Sniffer | |
phplint | PHP | PHP Code Linter [1] | |
php-cs-fixer | PHP | PHP Coding Standards Fixer | |
black | Python | The uncompromising Python code formatter | |
mypy | Python | Static source code analysis | |
pycodestyle | Python | Python style guide checker | |
pydocstyle | Python | Python docstyle checker | |
pylint | Python | Python source code, bug and quality checker | |
terraform-docs | Terraform | Terraform doc generator (TF 0.12 ready) [1] | |
terragrunt | Terraform | Terragrunt and Terraform | |
terragrunt-fmt | Terraform | terraform fmt for Terragrunt files [1] |
|
yamlfmt | Yaml | Format Yaml files [1] | |
yamllint | Yaml | Lint Yaml files |
[1] Uses a shell wrapper to add enhanced functionality not available by original project.
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.
Copyright (c) 2019 cytopia