diff --git a/Dockerfile b/Dockerfile index cb554d2..b69b114 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,11 @@ ADD https://raw.githubusercontent.com/crops/extsdk-container/master/restrict_use COPY distro-entry.sh poky-entry.py poky-launch.sh /usr/bin/ COPY sudoers.usersetup /etc/ +RUN echo -e "\n# ssh-agent socket bind-mounted from host\n"\ +"if [ -s /tmp/ssh-auth-sock ]; then\n"\ +" export SSH_AUTH_SOCK=/tmp/ssh-auth-sock\n"\ +"fi\n" >> /etc/skel/.bashrc + # For ubuntu, do not use dash. RUN which dash &> /dev/null && (\ echo "dash dash/sh boolean false" | debconf-set-selections && \ diff --git a/poky-container b/poky-container new file mode 100755 index 0000000..f2192e2 --- /dev/null +++ b/poky-container @@ -0,0 +1,87 @@ +#!/bin/bash + +usage() { +cat << EOF +Usage: + poky-container list + List available images + + poky-container run IMAGE [HOST_WORKDIR] + Run the selected image on a specific location + +Parameters: + IMAGE The name of the image to run + HOST_WORKDIR The working directory, ie, location if the workspace + on the host, which will show as /workdir in the + container. + By default, the current working directory is used. + +EOF +} + + +list() { +cat << EOF +AlmaLinux: + alma-8 alma-9 + +CentOS: + centos-7 + +Debian: + debian-9 debian-10 debian-11 + +Fedora: + fedora-33 fedora-34 fedora-35 fedora-36 + +OpenSuse: + opensuse-15.2 opensuse-15.3 opensuse-15.4 + +Ubuntu: + ubuntu-16.04 ubuntu-18.04 ubuntu-20.04 ubuntu-22.04 + +EOF +} + +run() { + CONTAINER_WORKDIR=/workdir + HOST_WORKDIR=$(readlink -f .) + if [ $# -eq 2 ]; then + HOST_WORKDIR=$(readlink -f $2) + elif [ $# -ne 1 ]; then + echo "Error: Invalid arguments" + usage + exit 1 + fi + IMAGE=$1 + + SSH_AUTH_SOCK_MOUNT="" + if [ -z "$SSH_AUTH_SOCK" ]; then + eval $(ssh-agent) + SSH_AUTH_SOCK_MOUNT="--mount type=bind,source=$(readlink -f $SSH_AUTH_SOCK),destination=/tmp/ssh-auth-sock" + fi + + docker run --rm -it -v $HOST_WORKDIR:$CONTAINER_WORKDIR \ + $SSH_AUTH_SOCK_MOUNT \ + crops/poky:$IMAGE --workdir=$CONTAINER_WORKDIR +} + + +CMD=$1 +shift + +case $CMD in + list) + list + ;; + run) + run $@ + ;; + *) + usage + ;; +esac + + + +