Skip to content

Commit adb6251

Browse files
authored
Merge pull request #74 from teamssix/main
perf: Package TerraformGoat as a Docker image to enhance the experien…
2 parents 03babb1 + 362773d commit adb6251

File tree

4 files changed

+160
-89
lines changed

4 files changed

+160
-89
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: dockerfile_ci
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "Dockerfile"
8+
- ".github/workflows/dockerfile_ci.yml"
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- "Dockerfile"
13+
- ".github/workflows/dockerfile_ci.yml"
14+
15+
env:
16+
DOCKER_LOGIN_NAME: ${{ secrets.DOCKER_LOGIN_NAME }}
17+
DOCKER_LOGIN_PASS: ${{ secrets.DOCKER_LOGIN_PASS }}
18+
DOCKER_TAG: "0.0.4"
19+
jobs:
20+
docker:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: checkout code
25+
uses: actions/checkout@v2
26+
- name: login aliyun docker hub
27+
run: echo "${{ env.DOCKER_LOGIN_PASS }}" | docker login registry.cn-beijing.aliyuncs.com -u "${{ env.DOCKER_LOGIN_NAME }}" --password-stdin
28+
- name: build
29+
run: |
30+
docker build -t registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_aliyun:${{ env.DOCKER_TAG }} --target aliyun .
31+
docker build -t registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_tencentcloud:${{ env.DOCKER_TAG }} --target tencentcloud .
32+
docker build -t registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_huaweicloud:${{ env.DOCKER_TAG }} --target huaweicloud .
33+
docker build -t registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_aws:${{ env.DOCKER_TAG }} --target aws .
34+
docker build -t registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_gcp:${{ env.DOCKER_TAG }} --target gcp .
35+
docker build -t registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_azure:${{ env.DOCKER_TAG }} --target azure .
36+
- name: push
37+
run: |
38+
docker push registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_aliyun:${{ env.DOCKER_TAG }}
39+
docker push registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_tencentcloud:${{ env.DOCKER_TAG }}
40+
docker push registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_huaweicloud:${{ env.DOCKER_TAG }}
41+
docker push registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_aws:${{ env.DOCKER_TAG }}
42+
docker push registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_gcp:${{ env.DOCKER_TAG }}
43+
docker push registry.cn-beijing.aliyuncs.com/huoxian_pub/terraformgoat_azure:${{ env.DOCKER_TAG }}

Dockerfile

Lines changed: 102 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,113 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:20.04 AS aliyun
22
LABEL maintainer="HuoCorp research lab <https://github.com/HuoCorp>"
3+
COPY . /TerraformGoat
4+
RUN apt-get update -y && \
5+
apt-get -yq --no-install-recommends install gnupg2 groff less lsb-release software-properties-common curl vim && \
6+
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - 2>/dev/null && \
7+
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
8+
apt-get update && \
9+
apt-get -yq --no-install-recommends install terraform && \
10+
apt-get clean && \
11+
apt-get autoclean && \
12+
echo "plugin_cache_dir = \"$HOME/.terraform.d/plugin-cache\"" > ~/.terraformrc && \
13+
mkdir -p $HOME/.terraform.d/plugin-cache && \
14+
cd /TerraformGoat/aliyun/oss/bucket_http_enable && terraform init && \
15+
curl -O "https://aliyuncli.alicdn.com/aliyun-cli-linux-3.0.32-amd64.tgz" && \
16+
tar xzvf aliyun-cli-linux-3.0.32-amd64.tgz && \
17+
cp aliyun /usr/local/bin && \
18+
echo "bash init.sh" >> ~/.bashrc
19+
WORKDIR /TerraformGoat
20+
21+
FROM ubuntu:20.04 AS tencentcloud
22+
LABEL maintainer="HuoCorp research lab <https://github.com/HuoCorp>"
23+
COPY . /TerraformGoat
24+
RUN apt-get update -y && \
25+
apt-get -yq --no-install-recommends install curl gnupg2 groff less lsb-release python3-pip software-properties-common vim && \
26+
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - 2>/dev/null && \
27+
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
28+
apt-get update && \
29+
apt-get -yq --no-install-recommends install terraform && \
30+
apt-get clean && \
31+
apt-get autoclean && \
32+
echo "plugin_cache_dir = \"$HOME/.terraform.d/plugin-cache\"" > ~/.terraformrc && \
33+
mkdir -p $HOME/.terraform.d/plugin-cache && \
34+
cd /TerraformGoat/tencentcloud/cos/bucket_acl_readable && terraform init && \
35+
pip install tccli && \
36+
echo "bash init.sh" >> ~/.bashrc
37+
WORKDIR /TerraformGoat
338

39+
FROM ubuntu:20.04 AS huaweicloud
40+
LABEL maintainer="HuoCorp research lab <https://github.com/HuoCorp>"
41+
COPY . /TerraformGoat
442
RUN apt-get update -y && \
5-
apt-get install -qy gnupg2 && \
6-
apt-get install -qy curl && \
7-
apt-get install -qy vim && \
8-
apt-get install -qy lsb-release && \
9-
apt-get install -qy software-properties-common && \
10-
apt-get install -y -qq less && \
11-
apt-get install -y -qq groff && \
43+
apt-get -yq --no-install-recommends install gnupg2 groff less lsb-release software-properties-common curl vim && \
1244
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - 2>/dev/null && \
1345
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
1446
apt-get update && \
15-
apt-get install terraform && \
47+
apt-get -yq --no-install-recommends install terraform && \
48+
apt-get clean && \
49+
apt-get autoclean && \
1650
echo "plugin_cache_dir = \"$HOME/.terraform.d/plugin-cache\"" > ~/.terraformrc && \
1751
mkdir -p $HOME/.terraform.d/plugin-cache && \
18-
echo "bash install_cloud_cli.sh " >> ~/.bashrc
52+
cd /TerraformGoat/huaweicloud/obs/bucket_object_traversal && terraform init && \
53+
curl -sSL https://hwcloudcli.obs.cn-north-1.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && echo "y" | bash ./hcloud_install.sh -y && \
54+
echo "bash init.sh" >> ~/.bashrc
55+
WORKDIR /TerraformGoat
1956

57+
FROM ubuntu:20.04 AS aws
58+
LABEL maintainer="HuoCorp research lab <https://github.com/HuoCorp>"
2059
COPY . /TerraformGoat
60+
RUN apt-get update -y && \
61+
apt-get -yq --no-install-recommends install gnupg2 groff less lsb-release software-properties-common curl unzip vim && \
62+
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - 2>/dev/null && \
63+
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
64+
apt-get update && \
65+
apt-get -yq --no-install-recommends install terraform && \
66+
apt-get clean && \
67+
apt-get autoclean && \
68+
echo "plugin_cache_dir = \"$HOME/.terraform.d/plugin-cache\"" > ~/.terraformrc && \
69+
mkdir -p $HOME/.terraform.d/plugin-cache && \
70+
cd /TerraformGoat/aws/s3/bucket_acl_readable && terraform init && \
71+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
72+
unzip awscliv2.zip && \
73+
./aws/install && \
74+
echo "bash init.sh" >> ~/.bashrc
75+
WORKDIR /TerraformGoat
76+
77+
FROM ubuntu:20.04 AS gcp
78+
LABEL maintainer="HuoCorp research lab <https://github.com/HuoCorp>"
79+
COPY . /TerraformGoat
80+
RUN apt-get update -y && \
81+
apt-get -yq --no-install-recommends install gnupg2 groff less lsb-release software-properties-common curl vim && \
82+
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - 2>/dev/null && \
83+
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
84+
apt-get update && \
85+
apt-get -yq --no-install-recommends install terraform && \
86+
apt-get clean && \
87+
apt-get autoclean && \
88+
echo "plugin_cache_dir = \"$HOME/.terraform.d/plugin-cache\"" > ~/.terraformrc && \
89+
mkdir -p $HOME/.terraform.d/plugin-cache && \
90+
cd /TerraformGoat/gcp/cs/bucket_acl_writable && terraform init && \
91+
curl -O "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-377.0.0-linux-x86_64.tar.gz" && \
92+
tar -xf google-cloud-sdk-377.0.0-linux-x86_64.tar.gz && \
93+
N y /root/.bashrc | ./google-cloud-sdk/install.sh && \
94+
echo "bash init.sh" >> ~/.bashrc
95+
WORKDIR /TerraformGoat
96+
97+
FROM ubuntu:20.04 AS azure
98+
LABEL maintainer="HuoCorp research lab <https://github.com/HuoCorp>"
99+
COPY . /TerraformGoat
100+
RUN apt-get update -y && \
101+
apt-get -yq --no-install-recommends install gnupg2 groff less lsb-release software-properties-common curl vim && \
102+
curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - 2>/dev/null && \
103+
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
104+
apt-get update && \
105+
apt-get -yq --no-install-recommends install terraform && \
106+
apt-get clean && \
107+
apt-get autoclean && \
108+
echo "plugin_cache_dir = \"$HOME/.terraform.d/plugin-cache\"" > ~/.terraformrc && \
109+
mkdir -p $HOME/.terraform.d/plugin-cache && \
110+
cd /TerraformGoat/azure/blob/blob_public_access && terraform init && \
111+
curl -sL https://aka.ms/InstallAzureCLIDeb | bash && \
112+
echo "bash init.sh" >> ~/.bashrc
21113
WORKDIR /TerraformGoat

init.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
echo -e "\e[32m"
3+
cat << "EOF"
4+
_____ __ ___ _
5+
/__ \___ _ __ _ __ __ _ / _| ___ _ __ _ __ ___ / _ \___ __ _| |_
6+
/ /\/ _ \ '__| '__/ _` | |_ / _ \| '__| '_ ` _ \ / /_\/ _ \ / _` | __|
7+
/ / | __/ | | | | (_| | _| (_) | | | | | | | / /_\\ (_) | (_| | |_
8+
\/ \___|_| |_| \__,_|_| \___/|_| |_| |_| |_\____/\___/ \__,_|\__|
9+
EOF
10+
echo -e "
11+
Welcome To TerraformGoat v0.0.4
12+
13+
Repository URL: https://github.com/HuoCorp/TerraformGoat.git
14+
15+
------------------------------------------------------------------------\033[0m"

install_cloud_cli.sh

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)