forked from cytopia/docker-terraform-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-0.12
57 lines (50 loc) · 1.69 KB
/
Dockerfile-0.12
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
FROM golang:alpine3.11 as builder
# Install dependencies
RUN set -x \
&& apk add --no-cache \
bash \
curl \
gcc \
git \
make \
musl-dev \
&& curl https://raw.githubusercontent.com/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/terraform-docs/terraform-docs \
&& cd /go/src/github.com/terraform-docs/terraform-docs \
&& if [ "${VERSION}" != "latest" ]; then \
git checkout v${VERSION}; \
fi \
# Build terraform-docs latest
&& if [ "${VERSION}" = "latest" ]; then \
make gox \
&& make build-all GOOS=linux GOARCH=amd64 \
&& mv bin/terraform-docs-${VERSION}-linux-amd64 /usr/local/bin/terraform-docs; \
# Build terraform-docs 0.8.0-rc.1 and above
else \
make gox \
&& make build-all GOOS=linux GOARCH=amd64 \
&& mv bin/terraform-docs-${VERSION}-linux-amd64 /usr/local/bin/terraform-docs; \
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.11
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.12.sh /docker-entrypoint.sh
WORKDIR /data
CMD ["terraform-docs", "--version"]
ENTRYPOINT ["/docker-entrypoint.sh"]