-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathDockerfile
51 lines (49 loc) · 1.43 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
FROM python:3.12.9-alpine3.21
RUN apk update \
&& apk add curl zip git unzip
# Get Terraform
ARG TF_VERSION=latest
RUN set -eux \
&& if [ "${TF_VERSION}" = "latest" ]; then \
VERSION="$( curl -sS https://releases.hashicorp.com/terraform/ \
| tac | tac \
| grep -Eo '/terraform/[.0-9]+/\"' \
| grep -Eo '[.0-9]+' \
| sort -V \
| tail -1 )"; \
else \
VERSION="$( curl -sS https://releases.hashicorp.com/terraform/ \
| tac | tac \
| grep -Eo "/terraform/${TF_VERSION}\.[.0-9]+/\"" \
| grep -Eo '[.0-9]+' \
| sort -V \
| tail -1 )"; \
fi \
\
# Get correct architecture
&& if [ "$(dpkg --print-architecture | awk -F'-' '{print $NF}' )" = "i386" ]; then\
ARCH=386; \
elif [ "$(uname -m)" = "x86_64" ]; then \
ARCH=amd64; \
elif [ "$(uname -m)" = "aarch64" ]; then \
ARCH=arm64; \
elif [ "$(uname -m)" = "armv7l" ]; then \
ARCH=arm; \
fi \
\
&& curl --fail -sS -L -O \
https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_linux_${ARCH}.zip \
&& unzip terraform_${VERSION}_linux_${ARCH}.zip -d /usr/bin \
&& chmod +x /usr/bin/terraform \
&& rm -f terraform_${VERSION}_linux_${ARCH}.zip
RUN adduser -D aws2tf
RUN git clone -b python https://github.com/aws-samples/aws2tf.git /aws2tf
RUN chown -R aws2tf /aws2tf
USER aws2tf
WORKDIR /aws2tf
#install dependencies
RUN pip install -r requirements.txt
ENV PYTHONUNBUFFERED=1
# Set the entrypoint
ENTRYPOINT ["python", "aws2tf.py"]
CMD []