From 58cc59f3a2949741681c51c3b5a00b2e092b78b2 Mon Sep 17 00:00:00 2001 From: Benjamin Schmid Date: Mon, 25 May 2020 13:43:43 +0200 Subject: [PATCH] feat(*): Provide a wireframe for a Docker image with included AWS CLI tool Based on @blagerweij solution in the AWS CLI issue tracker: https://github.com/aws/aws-cli/issues/4685#issuecomment-615872019 --- Dockerfile | 29 +++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 11 +++++++++++ 3 files changed, 61 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..646bcdf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM docker:stable + +ENV GLIBC_VER=2.31-r0 + +# install glibc compatibility for alpine +RUN apk --no-cache add \ + binutils \ + curl \ + && curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \ + && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \ + && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \ + && apk add --no-cache \ + glibc-${GLIBC_VER}.apk \ + glibc-bin-${GLIBC_VER}.apk \ + && curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \ + && unzip awscliv2.zip \ + && aws/install \ + && rm -rf \ + awscliv2.zip \ + aws \ + /usr/local/aws-cli/v2/*/dist/aws_completer \ + /usr/local/aws-cli/v2/*/dist/awscli/data/ac.index \ + /usr/local/aws-cli/v2/*/dist/awscli/examples \ + && apk --no-cache del \ + binutils \ + curl \ + && rm glibc-${GLIBC_VER}.apk \ + && rm glibc-bin-${GLIBC_VER}.apk \ + && rm -rf /var/cache/apk/* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c24f76b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Benjamin Schmid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e02fd7b --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Docker for Docker-in-Docker (`dind`) with Amazon AWS CLI `awscli` + +If you face the simple problem that you want to to a simple `aws ecr set-login-password … | docker login …` inside your Docker-based CI you stumble over the following problems: + +* The official `docker:stable` Image does not contain Python, `pip` or `aws` CLI tool installed +* The popular `awscli` images do not have Docker support +* **Even manually installing `awscli` into `docker:stable` [as described in the official AWS CLI documentation](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html) does not work,** + +The last point is because `docker:stable` is based on Alpine Liinux, and awscli does not work on Alpine distribution due to missing glibc libraries. + +This repository reflects a workaround as described by @blagerweij in [this upstream issue](https://github.com/aws/aws-cli/issues/4685#issuecomment-615872019) \ No newline at end of file