From 1b3bd0dbe79db58d865ee30a44addc96389343ed Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Wed, 1 Nov 2023 09:56:04 +0100 Subject: [PATCH] Switch to alpine and manually provide terraform --- Dockerfile | 9 +++++---- tool.sh | 9 ++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index bf8f450..ec3032b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM amazonlinux:2023 +FROM alpine +ARG TARGETARCH -RUN yum install -y yum-utils shadow-utils -RUN yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo -RUN yum -y install terraform +RUN wget "https://releases.hashicorp.com/terraform/1.6.2/terraform_1.6.2_linux_$TARGETARCH.zip" -O "/tmp/terraform_1.6.2_linux_$TARGETARCH.zip" \ + && unzip "/tmp/terraform_1.6.2_linux_$TARGETARCH.zip" -d /usr/local/bin \ + && chmod +x /usr/local/bin/terraform LABEL maintainer="docker@2martens.de" description="Terraform for Drone" COPY tool.sh /usr/local/bin diff --git a/tool.sh b/tool.sh index 3598a48..3e6077a 100644 --- a/tool.sh +++ b/tool.sh @@ -1,7 +1,8 @@ #!/bin/sh working_dir=$(pwd) -cd "$PLUGIN_PATH" || exit 1 +echo "change to $working_dir/$PLUGIN_PATH" +cd "$working_dir/$PLUGIN_PATH" || exit 1 terraform init if [ "$PLUGIN_AUTO_APPROVE" = "true" ] then @@ -15,6 +16,8 @@ then else command="apply" fi -TF_TOKEN_app_terraform_io=$PLUGIN_API_TOKEN terraform "$command" -input=false"$auto_approve" -TF_TOKEN_app_terraform_io=$PLUGIN_API_TOKEN terraform output -json > "$working_dir/terraform_output" +echo "Run terraform init" +TF_TOKEN_app_terraform_io="$PLUGIN_API_TOKEN" terraform init +TF_TOKEN_app_terraform_io="$PLUGIN_API_TOKEN" terraform "$command" -input=false"$auto_approve" +TF_TOKEN_app_terraform_io="$PLUGIN_API_TOKEN" terraform output -json > "$working_dir/terraform_output" cd "$working_dir" || exit 1