Skip to content

Commit

Permalink
download terraform binary
Browse files Browse the repository at this point in the history
  • Loading branch information
shashitnak committed May 23, 2024
1 parent 1cd4789 commit 67c09d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
13 changes: 0 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,4 @@ COPY fly/Dockerfile /fly/Dockerfile
RUN apk upgrade --no-cache && apk update --no-cache
RUN apk add --no-cache curl jq go

RUN curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest \
| jq --raw-output .zipball_url \
| xargs wget -O /tmp/terraform.zip
RUN unzip /tmp/terraform.zip -d /tmp
RUN go build

FROM alpine:latest

COPY --from=builder /entrypoint.sh /entrypoint.sh
COPY --from=builder /aws/tailcall.tf /aws/tailcall.tf
COPY --from=builder /fly/Dockerfile /fly/Dockerfile
COPY --from=builder /tmp/terraform /usr/local/bin/terraform

ENTRYPOINT /bin/sh /entrypoint.sh
11 changes: 9 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

get_latest_release() {
get_latest_version() {
curl https://api.github.com/repos/$1/$2/releases/latest -s | jq .name -r
}

Expand All @@ -11,14 +11,21 @@ export TF_VAR_AWS_IAM_ROLE=$AWS_IAM_ROLE
export TF_VAR_AWS_LAMBDA_FUNCTION_NAME=$AWS_LAMBDA_FUNCTION_NAME

if [ "$TAILCALL_VERSION" = "latest" ]; then
TAILCALL_VERSION=$(get_latest_release tailcallhq tailcall)
TAILCALL_VERSION=$(get_latest_version tailcallhq tailcall)
fi
export TF_VAR_TAILCALL_VERSION=$TAILCALL_VERSION

get_tailcall_config() {
cp "$TAILCALL_CONFIG" .
}

setup_terraform() {
TERRAFORM_VERSION=$(get_latest_version hashicorp terraform)
wget -O /tmp/terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
unzip /tmp/terraform.zip -d /tmp && rm /tmp/terraform.zip
mv /tmp/*/terraform /usr/local/bin/terraform
}

setup_flyctl() {
curl -L https://fly.io/install.sh | sh
export FLYCTL_INSTALL="/root/.fly"
Expand Down

0 comments on commit 67c09d3

Please sign in to comment.