From 234561ad6377458d90a7630fa54452c8d5a7a9c2 Mon Sep 17 00:00:00 2001 From: peterdeme Date: Wed, 2 Oct 2024 17:26:39 +0200 Subject: [PATCH] Add aws `session-manager-plugin` to `aws` image Signed-off-by: peterdeme --- .github/workflows/build.yml | 1 + aws/Dockerfile | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 580f03c..ecd889f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,6 +53,7 @@ jobs: if [ "${{ matrix.folder }}" == "aws" ]; then docker run --rm ${{ env.IMAGE_NAME }} sh -c "python3 -c \"import boto3; print(boto3.__version__)\"" + docker run --rm ${{ env.IMAGE_NAME }} session-manager-plugin --version fi if [ "${{ matrix.folder }}" == "gcp" ]; then diff --git a/aws/Dockerfile b/aws/Dockerfile index 32b13ef..97d804c 100644 --- a/aws/Dockerfile +++ b/aws/Dockerfile @@ -1,5 +1,47 @@ ARG REPOSITORY_BASE_PATH +# Go version taken from here: https://github.com/aws/session-manager-plugin/blob/mainline/Dockerfile +# FROM golang:1.17-alpine AS ssm-builder + +# ARG VERSION=1.2.650.0 +# RUN set -ex && apk add --no-cache make git gcc libc-dev curl bash zip && \ +# curl -sLO https://github.com/aws/session-manager-plugin/archive/${VERSION}.tar.gz && \ +# mkdir -p /go/src/github.com && \ +# tar xzf ${VERSION}.tar.gz && \ +# mv session-manager-plugin-${VERSION} /go/src/github.com/session-manager-plugin && \ +# cd /go/src/github.com/session-manager-plugin && \ +# make release +FROM alpine AS ssm-builder + +# Architecture is either x86_64 or arm64 +# RUN apk add dkpg +ARG TARGETARCH + +RUN apk add dpkg curl; \ + if [ "$TARGETARCH" = "arm64" ]; then \ + curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_arm64/session-manager-plugin.deb" -o "session-manager-plugin.deb"; \ + else \ + curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"; \ + fi; \ + dpkg -x session-manager-plugin.deb session-manager-plugin + # cp session-manager-plugin/usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/bin/session-manager-plugin; \ + # readlink -f session-manager-plugin/usr/local/sessionmanagerplugin/bin/session-manager-plugin + +# RUN dpkg -i session-manager-plugin.deb +# RUN dpkg -x session-manager-plugin.deb session-manager-plugin && +# cp session-manager-plugin/usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/bin/session-manager-plugin + +# ARG REPOSITORY_BASE_PATH + FROM ${REPOSITORY_BASE_PATH}:latest +# COPY --from=ssm-builder /go/src/github.com/session-manager-plugin/bin/linux_*_plugin/session-manager-plugin /usr/local/bin/ +COPY --from=ssm-builder /session-manager-plugin/usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/ + +USER root + +RUN chmod +x /usr/local/bin/session-manager-plugin + +USER spacelift + RUN pip install boto3 --break-system-packages