Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alpine support? #12

Open
artempartos opened this issue Sep 14, 2021 · 15 comments
Open

alpine support? #12

artempartos opened this issue Sep 14, 2021 · 15 comments

Comments

@artempartos
Copy link

No description provided.

@Yangtao-Hua
Copy link
Contributor

Hi @artempartos, would you mind add more details for the request. Do you mean to use session manager plugin in alpine linux, or facing some issues when connecting to an alpine linux target?

@artempartos
Copy link
Author

Sorry, I mean I want to use it on alpine machine, it can't use rpm or deb packages.
Could you build bin for alpine as well, please?

@skwashd
Copy link

skwashd commented Oct 24, 2021

Trying to build the binary on alpine fails due to a hardcoded dependency on bash. Based on my testing /bin/sh is enough in this case. Alpine ships with busybox and it works with /bin/sh. I'd really like to be able to remove my sed hack from my Dockerfile.

This is the error when building for Alpine:

#12 13.86 /path/to/source/session-manager-plugin/Tools/src/checkstyle.sh
#12 13.86 env: can't execute 'bash': No such file or directory
#12 13.86 make: *** [makefile:18: checkstyle] Error 127

skwashd added a commit to skwashd/session-manager-plugin that referenced this issue Oct 24, 2021
Should make resolving aws#12 easier
skwashd added a commit to skwashd/session-manager-plugin that referenced this issue Oct 24, 2021
Should make resolving aws#12 easier
skwashd added a commit to skwashd/session-manager-plugin that referenced this issue Oct 24, 2021
Related changes:
* Fix checks for gofmt and gofmt errors
* Use $() over ``

Should make resolving aws#12 easier
skwashd added a commit to skwashd/session-manager-plugin that referenced this issue Oct 24, 2021
Related changes:
* Fix checks for gofmt and gofmt errors
* Use $() over ``

Should make resolving aws#12 easier
@ikedam
Copy link

ikedam commented Oct 24, 2021

+1 for supporting alpine.
-1 for switching to bash sh for alpine.

You can easily install bash on alpine with apk add bash.

@Skaronator
Copy link

Since the session manager client seems to be only a single binary I was able to just copy the binary from the deb to my alpine container with a multistage Dockerfile:

FROM ubuntu:20.04 as sessionmanagerplugin

RUN apt-get update \
    && apt-get install -y curl \
    && curl -Lo "session-manager-plugin.deb" "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" \
    && dpkg -i "session-manager-plugin.deb"


FROM alpine:2.13

COPY --from=sessionmanagerplugin /usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/

Not the cleanest solution but better than compiling it myself IMO.

@jradikk
Copy link

jradikk commented Nov 18, 2021

Inspired by this comment, Dockerfile for session-manager-plugin compilation for Alpine

FROM golang:1.15.3-alpine as ssm-builder

ARG VERSION=1.2.279.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

COPY --from=ssm-builder /go/src/github.com/session-manager-plugin/bin/linux_amd64_plugin/session-manager-plugin /usr/local/bin/

Keep in mind that until this issue is resolved, golang version has to be < 1.16

@rinarakaki
Copy link

I hope session-manager-plugin is gonna be the next! aws/aws-cli#4685

@lrodrigo-cluey
Copy link

lrodrigo-cluey commented Sep 1, 2023

@Skaronator

Hi, I'm still getting "SessionManagerPlugin is not found. Please refer to SessionManager Documentation here: http://docs.aws.amazon.com/console/systems-manager/session-manager-plugin-not-found"

Do I need to do anything else with file /usr/local/bin/session-manager-plugin ?

@dlambda
Copy link

dlambda commented Oct 13, 2023

Initially missed @Skaronator's solution because the following entry had more attention - nice work thanks!

My improvement on this is:

FROM ubuntu:20.04 as sessionmanagerplugin

ADD https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb .
RUN dpkg -i "session-manager-plugin.deb"


FROM alpine

COPY --from=sessionmanagerplugin /usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/

#RUN apk add -U gcompat

since it's cached.

Had tried the alpine builder, then used AWS's image for a slightly cleaner set of commands, but both unnecessarily build the binary each time and it's a significant wait.

@raysn0w
Copy link

raysn0w commented Oct 20, 2023

@Skaronator

Hi, I'm still getting "SessionManagerPlugin is not found. Please refer to SessionManager Documentation here: http://docs.aws.amazon.com/console/systems-manager/session-manager-plugin-not-found"

Do I need to do anything else with file /usr/local/bin/session-manager-plugin ?

Did you ever figure it out? I'm getting the same issue:

/app # /usr/local/bin/session-manager-plugin
sh: /usr/local/bin/session-manager-plugin: not found

@justsomescripts
Copy link

@raysn0w you need to install gcompat for it to work as the plugin depends on glibc (https://wiki.alpinelinux.org/wiki/Running_glibc_programs).

@Edmund-Loh
Copy link

@raysn0w you need to install gcompat for it to work as the plugin depends on glibc (https://wiki.alpinelinux.org/wiki/Running_glibc_programs).

I have installed gcompat but still get the following:

~ # session-manager-plugin
ld-linux-x86-64.so.2: /usr/local/bin/session-manager-plugin: Not a valid dynamic program

I installed a glibc package instead: https://github.com/sgerrand/alpine-pkg-glibc?tab=readme-ov-file

That worked, but I am still wondering why gcompatdid not work.

@bobbymaher
Copy link

bobbymaher commented Apr 21, 2024

This works for Alpine docker under ARM / M1/Mx Mac. Tested on Alpine 3.18.6

apk add dpkg
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_arm64/session-manager-plugin.deb" -o "session-manager-plugin.deb"
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
chmod +x /usr/bin/session-manager-plugin

@skwashd
Copy link

skwashd commented Jul 7, 2024

Copying a binary from another source doesn't solve the issue that as is today the session manager plugin can't be built from source on Alpine Linux.

@peterdeme
Copy link

This is the solution ended up working for us, a continuation of @bobbymaher's:

FROM alpine AS ssm-builder

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

FROM alpine

COPY --from=ssm-builder /session-manager-plugin/usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/

ARG TARGETARCH

# session-manager-plugin requires gcompat on amd64
RUN if [ "$TARGETARCH" = "amd64" ]; then \
     apk add --no-cache gcompat; \
    fi

RUN chmod +x /usr/local/bin/session-manager-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests