From dbf3195f533a7134dd479a3ca886a4d4fc3f0375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Fri, 18 Nov 2022 17:14:19 +0000 Subject: [PATCH 1/3] add poky-container helper script * poky-container: helper script to list available containers and running a container without the need to remember complex commands. --- poky-container | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 poky-container diff --git a/poky-container b/poky-container new file mode 100755 index 0000000..f2e8d90 --- /dev/null +++ b/poky-container @@ -0,0 +1,83 @@ +#!/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 + +CentOS: + centos-7 centos-8 + +Debian: + debian-9 debian-10 debian-11 + +Fedora: + fedora-33 fedora-34 fedora-35 fedora-36 + +OpenSuse: + opensuse-15.2 opensuse-15.3 + +Ubuntu: + ubuntu-16.04 ubuntu-18.04 ubuntu-20.04 ubuntu-22.04 + +Other: + latest + +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 + + docker run --rm -it -v $HOST_WORKDIR:$CONTAINER_WORKDIR \ + crops/poky:$IMAGE --workdir=$CONTAINER_WORKDIR +} + + +CMD=$1 +shift + +case $CMD in + list) + list + ;; + run) + run $@ + ;; + *) + usage + ;; +esac + + + + From 2c6da329000a1eeb19a97a965b14df73a424a9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Fri, 18 Nov 2022 17:16:50 +0000 Subject: [PATCH 2/3] pass ssh-agent socket from host to container --- Dockerfile | 5 +++++ poky-container | 7 +++++++ 2 files changed, 12 insertions(+) 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 index f2e8d90..286711c 100755 --- a/poky-container +++ b/poky-container @@ -58,7 +58,14 @@ run() { 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 } From f845f8cf423d6afea3f85fed3f726e2be0fc6872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Fri, 18 Nov 2022 17:20:35 +0000 Subject: [PATCH 3/3] update list of containers --- poky-container | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/poky-container b/poky-container index 286711c..f2192e2 100755 --- a/poky-container +++ b/poky-container @@ -23,10 +23,10 @@ EOF list() { cat << EOF AlmaLinux: - alma-8 + alma-8 alma-9 CentOS: - centos-7 centos-8 + centos-7 Debian: debian-9 debian-10 debian-11 @@ -35,14 +35,11 @@ Fedora: fedora-33 fedora-34 fedora-35 fedora-36 OpenSuse: - opensuse-15.2 opensuse-15.3 + opensuse-15.2 opensuse-15.3 opensuse-15.4 Ubuntu: ubuntu-16.04 ubuntu-18.04 ubuntu-20.04 ubuntu-22.04 -Other: - latest - EOF }