From 502059ab563af8d7220c92dd5caaf28e7ccc2ac6 Mon Sep 17 00:00:00 2001 From: Aleksandr Kostousov Date: Tue, 5 Apr 2022 16:20:24 +0300 Subject: [PATCH 1/5] Replace awscli-v1 with awscli-v2.1.39 --- Dockerfile | 14 ++++++++------ README.md | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8e24d0..ec60bc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ ARG HELM_VERSION=3.2.1 ARG KUBECTL_VERSION=1.17.5 ARG KUSTOMIZE_VERSION=v3.8.1 ARG KUBESEAL_VERSION=v0.15.0 +ARG AWS_CLI_VERSION=2.1.39 # Install helm (latest release) # ENV BASE_URL="https://storage.googleapis.com/kubernetes-helm" @@ -42,12 +43,13 @@ RUN curl -sL "https://github.com/weaveworks/eksctl/releases/latest/download/eksc mv /tmp/eksctl /usr/bin && \ chmod +x /usr/bin/eksctl -# Install awscli -RUN apk add --update --no-cache python3 && \ - python3 -m ensurepip && \ - pip3 install --upgrade pip && \ - pip3 install awscli && \ - pip3 cache purge +# Install awscli v2 +RUN apk add --update --no-cache curl gcompat groff && \ + curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" -o "awscliv2.zip" && \ + unzip awscliv2.zip && rm awscliv2.zip && \ + ./aws/install -i /usr/bin/aws-cli -b /usr/bin && \ + chmod +x /usr/bin/aws && \ + rm -rf awscliv2.zip aws # https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html # Install aws-iam-authenticator diff --git a/README.md b/README.md index c1d7105..3939171 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ There is no `latest` tag for this image - [helm-push](https://github.com/chartmuseum/helm-push) (latest commit) - [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) (latest version when run the build) - [eksctl](https://github.com/weaveworks/eksctl) (latest version when run the build) -- [awscli v1](https://github.com/aws/aws-cli) (latest version when run the build) +- [awscli v2.1.39](https://github.com/aws/aws-cli) (latest version when run the build) - [kubeseal](https://github.com/bitnami-labs/sealed-secrets) (latest version when run the build) - General tools, such as bash, curl From f738614b344922e77a68264a5291587bf294f5d7 Mon Sep 17 00:00:00 2001 From: Aleksandr Kostousov Date: Tue, 5 Apr 2022 16:24:50 +0300 Subject: [PATCH 2/5] Removed redundant package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ec60bc7..da4f516 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ RUN curl -sL "https://github.com/weaveworks/eksctl/releases/latest/download/eksc chmod +x /usr/bin/eksctl # Install awscli v2 -RUN apk add --update --no-cache curl gcompat groff && \ +RUN apk add --update --no-cache gcompat groff && \ curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" -o "awscliv2.zip" && \ unzip awscliv2.zip && rm awscliv2.zip && \ ./aws/install -i /usr/bin/aws-cli -b /usr/bin && \ From 1209b0ad72d1fe22ef3e29b6f0ac9582add7dede Mon Sep 17 00:00:00 2001 From: Aleksandr Kostousov Date: Tue, 5 Apr 2022 17:02:01 +0300 Subject: [PATCH 3/5] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3939171..451b693 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ There is no `latest` tag for this image - [helm-push](https://github.com/chartmuseum/helm-push) (latest commit) - [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) (latest version when run the build) - [eksctl](https://github.com/weaveworks/eksctl) (latest version when run the build) -- [awscli v2.1.39](https://github.com/aws/aws-cli) (latest version when run the build) +- [awscli](https://github.com/aws/aws-cli) (v2.1.39) - [kubeseal](https://github.com/bitnami-labs/sealed-secrets) (latest version when run the build) - General tools, such as bash, curl From 7071cf253fefe368176589603e200b6c7e087bbe Mon Sep 17 00:00:00 2001 From: Aleksandr Kostousov Date: Thu, 14 Apr 2022 22:16:19 +0300 Subject: [PATCH 4/5] Updated README.md, added entrypoint script --- Dockerfile | 28 ++++++++++++++++++---------- README.md | 12 +++++++++++- entrypoint.sh | 4 ++++ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index da4f516..ac8e072 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,19 +43,23 @@ RUN curl -sL "https://github.com/weaveworks/eksctl/releases/latest/download/eksc mv /tmp/eksctl /usr/bin && \ chmod +x /usr/bin/eksctl +# Install awscli v1 +RUN apk add --update --no-cache python3 && \ + ln -s /usr/bin/python3 /usr/bin/python && \ + curl -sL "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscliv1.zip" && \ + unzip awscliv1.zip && \ + ./awscli-bundle/install -i /usr/local/aws-cli-v1 -b /usr/local/bin/awsv1 && \ + chmod +x /usr/local/bin/awsv1 && \ + rm -rf awscliv1.zip awscli-bundle + # Install awscli v2 RUN apk add --update --no-cache gcompat groff && \ curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" -o "awscliv2.zip" && \ - unzip awscliv2.zip && rm awscliv2.zip && \ - ./aws/install -i /usr/bin/aws-cli -b /usr/bin && \ - chmod +x /usr/bin/aws && \ - rm -rf awscliv2.zip aws - -# https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html -# Install aws-iam-authenticator -RUN authenticator=$(aws --no-sign-request s3 ls s3://amazon-eks --recursive |grep aws-iam-authenticator$|grep amd64 |awk '{print $NF}' |sort -V|tail -1) && \ - aws --no-sign-request s3 cp s3://amazon-eks/${authenticator} /usr/bin/aws-iam-authenticator && \ - chmod +x /usr/bin/aws-iam-authenticator + unzip awscliv2.zip && \ + ./aws/install -i /usr/local/aws-cli-v2 -b /usr/local/bin && \ + chmod +x /usr/local/bin/aws && \ + mv /usr/local/bin/aws /usr/local/bin/awsv2 && \ + rm -rf awscliv2.zip aws # Install jq RUN apk add --update --no-cache jq @@ -68,4 +72,8 @@ RUN curl -sL https://github.com/bitnami-labs/sealed-secrets/releases/download/${ mv kubeseal /usr/bin/kubeseal && \ chmod +x /usr/bin/kubeseal +COPY entrypoint.sh entrypoint.sh + WORKDIR /apps + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 451b693..9673c21 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ There is no `latest` tag for this image - [helm-push](https://github.com/chartmuseum/helm-push) (latest commit) - [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) (latest version when run the build) - [eksctl](https://github.com/weaveworks/eksctl) (latest version when run the build) -- [awscli](https://github.com/aws/aws-cli) (v2.1.39) +- [awscliv1](https://github.com/aws/aws-cli) (latest version when run the build) +- [awscliv2](https://github.com/aws/aws-cli) (v2.1.39) - [kubeseal](https://github.com/bitnami-labs/sealed-secrets) (latest version when run the build) - General tools, such as bash, curl @@ -34,6 +35,15 @@ https://app.circleci.com/pipelines/github/alpine-docker/k8s https://hub.docker.com/r/alpine/k8s/tags/ +# Quick start +Set environmental variable `awscli` to `v2` to use awscliv2 by default, otherwise awscliv1 is used. + +To pass an environmental variable to a docker image use the `-e` option: + +``` +docker -e awscli=v2 ... +``` + # Why we need it Mostly it is used during CI/CD (continuous integration and continuous delivery) or as part of an automated build/deployment diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..59d696b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh +[ "v2" == "$awscli" ] && ln -s /usr/local/bin/awsv2 /usr/bin/aws || ln -s /usr/local/bin/awsv1 /usr/bin/aws + +exec "$@" \ No newline at end of file From b00181fe52f9f3bdf16155689b1c96a5aff39398 Mon Sep 17 00:00:00 2001 From: Aleksandr Kostousov Date: Thu, 14 Apr 2022 22:57:28 +0300 Subject: [PATCH 5/5] AWS Iam authenticator returned --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index ac8e072..3f9224d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,6 +61,12 @@ RUN apk add --update --no-cache gcompat groff && \ mv /usr/local/bin/aws /usr/local/bin/awsv2 && \ rm -rf awscliv2.zip aws +# https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html +# Install aws-iam-authenticator +RUN authenticator=$(awsv1 --no-sign-request s3 ls s3://amazon-eks --recursive |grep aws-iam-authenticator$|grep amd64 |awk '{print $NF}' |sort -V|tail -1) && \ + awsv1 --no-sign-request s3 cp s3://amazon-eks/${authenticator} /usr/bin/aws-iam-authenticator && \ + chmod +x /usr/bin/aws-iam-authenticator + # Install jq RUN apk add --update --no-cache jq