From 30d7f4f6da164008826510e212a0c27e4764bac7 Mon Sep 17 00:00:00 2001 From: Ashish Jullia Date: Thu, 23 Jan 2025 18:08:59 -0500 Subject: [PATCH] aws-cli - add support for arm --- Dockerfile | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a4e7af..322af3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,52 @@ +# FROM ubuntu:20.04 + +# ENV NVM_DIR /usr/local/nvm + +# # Install all dependencies, NVM, GitHub CLI, and other tools in a single RUN command +# RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ +# git \ +# jq \ +# unzip \ +# curl \ +# wget \ +# tar \ +# openssl \ +# python3 \ +# python3-pip \ +# && curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ +# && unzip awscliv2.zip \ +# && ./aws/install \ +# && curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \ +# && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \ +# && curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \ +# && chmod 700 get_helm.sh \ +# && ./get_helm.sh \ +# && git clone https://github.com/tfutils/tfenv.git ~/.tfenv \ +# && pip3 install urllib3==1.26.7 print-env \ +# && mkdir -p $NVM_DIR \ +# && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \ +# && . $NVM_DIR/nvm.sh \ +# # Install GitHub CLI +# && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ +# && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ +# && apt update \ +# && apt install gh \ +# # Clean up +# && apt-get clean \ +# && rm -rf /var/lib/apt/lists/* /awscliv2.zip + +# # Set environment path for tfenv and NVM +# ENV PATH="/root/.tfenv/bin:$NVM_DIR/versions/node/$(nvm version)/bin:$PATH" + +# # Create and set the working directory +# WORKDIR /work + +# # Copy the script into the container +# COPY ./script.sh / +# RUN chmod u+x /script.sh + + +# Base image FROM ubuntu:20.04 ENV NVM_DIR /usr/local/nvm @@ -13,16 +62,30 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ openssl \ python3 \ python3-pip \ - && curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ + # Install AWS CLI based on architecture + && ARCH=$(dpkg --print-architecture) \ + && if [ "$ARCH" = "amd64" ]; then \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"; \ + elif [ "$ARCH" = "arm64" ]; then \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"; \ + fi \ && unzip awscliv2.zip \ && ./aws/install \ - && curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \ + # Install kubectl based on architecture + && if [ "$ARCH" = "amd64" ]; then \ + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"; \ + elif [ "$ARCH" = "arm64" ]; then \ + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"; \ + fi \ && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \ + # Install Helm && curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \ && chmod 700 get_helm.sh \ && ./get_helm.sh \ + # Install tfenv && git clone https://github.com/tfutils/tfenv.git ~/.tfenv \ && pip3 install urllib3==1.26.7 print-env \ + # Install NVM && mkdir -p $NVM_DIR \ && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \ && . $NVM_DIR/nvm.sh \