Skip to content

Instantly share code, notes, and snippets.

@mendhak
Forked from jkpl/Dockerfile
Last active May 9, 2023 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendhak/5aeecc545241a7a04a676ad1512c816e to your computer and use it in GitHub Desktop.
Save mendhak/5aeecc545241a7a04a676ad1512c816e to your computer and use it in GitHub Desktop.
saml2aws Docker image, updated to work with symlink and get latest version

saml2aws Docker image

Due to the flakyness of Linux keyrings, saml2aws may get deadlocked. To get around this issue, saml2aws can be run in a Docker container. This Gist contains a Dockerfile and a helper script to use as drop-in replacement for saml2aws.

  1. Clone this Gist: https://gist.github.com/b5f76044eba1855b4222111b12a76dab.git

  2. Make the saml2aws.sh script executable:

    $ chmod +x /path/to/the/cloned/gist/saml2aws.sh
    
  3. Link the saml2aws.sh script to somewhere in your path. E.g.:

    $ ln -s /path/to/the/cloned/gist/saml2aws.sh ~/.local/bin/saml2aws
    

You should now be able to run saml2aws. The container will be automatically built, if it hasn't been built already.

$ saml2aws --help
FROM debian:stable-slim
RUN apt-get update && \
apt-get install -y ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
RUN CURRENT_VERSION=$(curl -Ls https://api.github.com/repos/Versent/saml2aws/releases/latest | grep 'tag_name' | cut -d> curl -L "https://github.com/Versent/saml2aws/releases/download/v${CURRENT_VERSION}/saml2aws_${CURRENT_VERSION}_linu> tar xvfz saml2aws.tar.gz && \
mv saml2aws /usr/local/bin/saml2aws && \
chmod +x /usr/local/bin/saml2aws && \
rm saml2aws.tar.gz
WORKDIR /saml2aws
RUN groupadd -g 10101 saml2aws && \
useradd -u 10101 -g saml2aws saml2aws && \
chown -R saml2aws:saml2aws /saml2aws
USER saml2aws:saml2aws
ENV HOME=/saml2aws
ENTRYPOINT [ "/usr/local/bin/saml2aws" ]
#!/usr/bin/env bash
set -euo pipefail
BASEDIR=$(dirname $(readlink -f $0))
if [ "$(docker images -q saml2aws)" = "" ]; then
docker build -t saml2aws "$BASEDIR"
fi
if [ ! -f "$HOME/.saml2aws" ]; then
touch "$HOME/.saml2aws"
fi
docker run --rm -it \
-u "$(id -u):$(id -g)" \
-v "$HOME/.saml2aws:/saml2aws/.saml2aws" \
-v "$HOME/.aws:/saml2aws/.aws" \
saml2aws \
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment