-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathDockerfile
107 lines (90 loc) · 4.22 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
FROM python:3.12-slim
ARG VERSION
WORKDIR /
RUN apt-get update && \
apt-get install --assume-yes \
curl unzip git wget zip git \
pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl xmlsec1 libgraphviz-dev libmagic1 \
gcc g++ libffi-dev python3-gpg && \
apt-get clean all
RUN bash -c 'if [ "$(uname -m)" == "aarch64" ]; \
then \
arch=arm64; \
else \
arch=amd64; \
fi; \
wget https://github.com/terraform-docs/terraform-docs/releases/download/v0.19.0/terraform-docs-v0.19.0-linux-${arch}.tar.gz && tar -zxvf terraform-docs-v0.19.0-linux-${arch}.tar.gz && chmod +x terraform-docs && mv terraform-docs /usr/local/bin/ && rm terraform-docs-v0.19.0-linux-${arch}.tar.gz'
RUN bash -c 'if [ "$(uname -m)" == "aarch64" ]; \
then \
arch=arm64; \
else \
arch=amd64; \
fi; \
wget https://github.com/aquasecurity/tfsec/releases/download/v1.28.4/tfsec-linux-${arch} -O /usr/local/bin/tfsec && \
chmod +x /usr/local/bin/tfsec'
# Download Infracost
RUN bash -c 'if [ "$(uname -m)" == "aarch64" ]; \
then \
arch=arm64; \
else \
arch=amd64; \
fi; \
wget https://github.com/infracost/infracost/releases/download/v0.10.22/infracost-linux-${arch}.tar.gz -O /tmp/infracost.tar.gz && \
tar -zxvf /tmp/infracost.tar.gz infracost-linux-${arch} && \
mv infracost-linux-${arch} /usr/local/bin/infracost && \
chmod +x /usr/local/bin/infracost && \
rm /tmp/infracost.tar.gz'
# Download tfswitch
RUN bash -c 'curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh | bash /dev/stdin 1.2.2'
# Install go
RUN bash -c 'if [ "$(uname -m)" == "aarch64" ]; \
then \
arch=arm64; \
else \
arch=amd64; \
fi; \
wget https://go.dev/dl/go1.20.10.linux-${arch}.tar.gz -O /tmp/go.tar.gz && \
tar -zxvf /tmp/go.tar.gz -C /usr/local && \
rm /tmp/go.tar.gz'
ENV PATH=$PATH:/usr/local/go/bin
# Install github.com/hashicorp/terraform-plugin-docs
RUN bash -c 'if [ "$(uname -m)" == "aarch64" ]; \
then \
arch=arm64; \
else \
arch=amd64; \
fi; \
wget https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.16.0/tfplugindocs_0.16.0_linux_${arch}.zip -O /tmp/tfplugindocs.zip && \
unzip /tmp/tfplugindocs.zip tfplugindocs && \
mv tfplugindocs /usr/local/bin/ && \
chmod +x /usr/local/bin/tfplugindocs && \
rm /tmp/tfplugindocs.zip'
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN mkdir bin licenses
# Create licenses for python packages
RUN pip install pip-licenses && pip-licenses --with-system --with-license-file --format=plain-vertical > licenses/LICENSES.python && pip uninstall --yes pip-licenses
# Copy licenses for deb packages
RUN mkdir licenses/deb
RUN bash -c 'pushd /usr/share/doc; for i in *; do mkdir /app/licenses/deb/$i; cp $i/{LICENSE,NOTICE,copyright} /app/licenses/deb/$i/; done; rmdir /app/licenses/deb/*; popd'
# Get licenses for installed binaries
RUN mkdir licenses/terraform-docs && wget https://github.com/terraform-docs/terraform-docs/raw/master/LICENSE -O ./licenses/terraform-docs/LICENSE
RUN mkdir licenses/tfsec && wget https://github.com/aquasecurity/tfsec/raw/master/LICENSE -O ./licenses/tfsec/LICENSE
RUN mkdir licenses/infracost && wget https://github.com/infracost/infracost/raw/master/LICENSE -O ./licenses/infracost/LICENSE
RUN mkdir licenses/terraform-switcher && wget https://github.com/warrensbox/terraform-switcher/raw/master/LICENSE -O ./licenses/terraform-switcher/LICENSE
RUN mkdir licenses/go && wget https://github.com/golang/go/raw/master/LICENSE -O ./licenses/go/LICENSE
RUN mkdir licenses/tfplugindocs && wget https://github.com/hashicorp/terraform-plugin-docs/raw/main/LICENSE -O ./licenses/tfplugindocs/LICENSE
COPY LICENSE .
COPY LICENSE.third-party .
COPY alembic.ini .
COPY terrareg.py .
COPY terrareg terrareg
COPY scripts scripts
RUN echo "$VERSION" > terrareg/version.txt
# Copy licenses for JS/CSS
RUN mkdir licenses/static
RUN bash -c 'for n in js css; do pushd /app/terrareg/static/$n; for i in *; do if [ -d $i ]; then mkdir /app/licenses/static/$i; cp $i/LICENSE /app/licenses/static/$i/; fi; done; popd; done'
ENV MANAGE_TERRAFORM_RC_FILE=True
EXPOSE 5000
CMD [ "bash", "scripts/entrypoint.sh" ]