-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
84 lines (78 loc) · 3.24 KB
/
Dockerfile
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
73
74
75
76
77
78
79
80
81
82
83
84
# Use a clean tiny image to store artifacts in
FROM alpine:3.20.3
# Labels for http://label-schema.org/rc1/#build-time-labels
# And for https://github.com/opencontainers/image-spec/blob/master/annotations.md
# And for https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions
ARG NAME="GitHub Action linting Terraform files"
ARG DESCRIPTION="GitHub Action that will run TFlint on Terraform files"
ARG REPO_URL="https://github.com/devops-infra/action-tflint"
ARG AUTHOR="Krzysztof Szyper / ChristophShyper / [email protected]"
ARG HOMEPAGE="https://christophshyper.github.io/"
ARG BUILD_DATE=2020-04-01T00:00:00Z
ARG VCS_REF=abcdef1
ARG VERSION=v0.0
LABEL \
com.github.actions.name="${NAME}" \
com.github.actions.author="${AUTHOR}" \
com.github.actions.description="${DESCRIPTION}" \
com.github.actions.color="purple" \
com.github.actions.icon="upload-cloud" \
org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.name="${NAME}" \
org.label-schema.description="${DESCRIPTION}" \
org.label-schema.usage="README.md" \
org.label-schema.url="${HOMEPAGE}" \
org.label-schema.vcs-url="${REPO_URL}" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.vendor="${AUTHOR}" \
org.label-schema.version="${VERSION}" \
org.label-schema.schema-version="1.0" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.authors="${AUTHOR}" \
org.opencontainers.image.url="${HOMEPAGE}" \
org.opencontainers.image.documentation="${REPO_URL}/blob/master/README.md" \
org.opencontainers.image.source="${REPO_URL}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.vendor="${AUTHOR}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.title="${NAME}" \
org.opencontainers.image.description="${DESCRIPTION}" \
maintainer="${AUTHOR}" \
repository="${REPO_URL}"
# Copy all needed files
COPY entrypoint.sh /
# Install needed packages
RUN set -eux ;\
chmod +x /entrypoint.sh ;\
apk update --no-cache ;\
apk add --no-cache \
bash~=5.2 \
curl~=8.10 \
git~=2.45 ;\
rm -rf /var/cache/* ;\
rm -rf /root/.cache/*
# Get Terraform by a specific version or search for the latest one
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
# hadolint ignore=SC2015
RUN VERSION="$( curl -LsS https://releases.hashicorp.com/terraform/ | grep -Eo '/[.0-9]+/' | grep -Eo '[.0-9]+' | sort -V | tail -1 )" ;\
for i in {1..5}; do curl -LsS \
https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_linux_amd64.zip -o ./terraform.zip \
&& break || sleep 15; done ;\
unzip ./terraform.zip ;\
rm -f ./terraform.zip ;\
chmod +x ./terraform ;\
mv ./terraform /usr/bin/terraform
# Get latest TFLint
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
# hadolint ignore=SC2015
RUN DOWNLOAD_URL="$( curl -LsS https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip" )" ;\
for i in {1..5}; do curl -LsS "${DOWNLOAD_URL}" -o ./tflint.zip && break || sleep 15; done ;\
unzip ./tflint.zip ;\
rm -f ./tflint.zip ;\
chmod +x ./tflint ;\
mv ./tflint /usr/bin/tflint
# Finish up
CMD ["tflint -v"]
WORKDIR /github/workspace
ENTRYPOINT ["/entrypoint.sh"]