@@ -54,6 +54,58 @@ Note that the plugin has to be built for target OS and architecture (`make build
54
54
and ` make install ` do that,) but if you want to redistribute the plugin for other
55
55
people to use you have to cross-compile it (for example you can use [ gox] .)
56
56
57
+ ## Docker
58
+
59
+ If you don't want cross-compile your plugin, you can pack it to the docker image.
60
+ So the only dependency needed the user/or a server machine is ` docker ` .
61
+
62
+ ### Building and publishing docker image
63
+
64
+ ``` bash
65
+ make docker
66
+ ```
67
+
68
+ Before you will build your docker image you have to replace very few things in the ` Makefile ` and the ` Dockerfile ` .
69
+
70
+ Things to replace:
71
+
72
+ ` Makefile ` :
73
+ - DOCKER_REGISTRY (could be any docker registry)
74
+ - PROJECT_OWNER (how the the place file in your registry. In our company it's something like ` devops/tools ` )
75
+ - BUILD_NAME (your project name should follow the patter ` tfdocs-format-<uniqueName> ` )
76
+
77
+ ` Dockerfile ` :
78
+ - all ** PROJECT_NAME** entries should be replaced with your project name( and it should follow the pattern ` tfdocs-format-<uniqueName> ` )
79
+
80
+ After all changes and ` make docker ` successful execution, you can push your new perfect image to the registry by:
81
+ ``` bash
82
+ make push
83
+ ```
84
+
85
+ ### Using docker image with your custom plugin
86
+
87
+ I'm a little lazy, and I made a simple sh script for easy usage of docker image with terraform-docs and the custom plugin:
88
+
89
+ ``` shell
90
+ #! /bin/bash
91
+
92
+ img=< link to the docker image with terraform-docs and custom plugin>
93
+
94
+ dir=$1
95
+ out_file=$2
96
+
97
+ function printMarkdownTo() {
98
+ pushd $1
99
+ (docker run --rm -v ` pwd` :` pwd` -w ` pwd` $img .) > $2
100
+ popd
101
+ }
102
+
103
+ printMarkdownTo ${dir} ${out_file}
104
+
105
+ ```
106
+
107
+ ## Links
108
+
57
109
[ terraform-docs ] : https://github.com/terraform-docs/terraform-docs
58
110
[ plugin SDK ] : https://github.com/terraform-docs/plugin-sdk
59
111
[ Go ] : https://golang.org/
0 commit comments