From d44356cf33f47bcc57ddbb4e98fb0d66d8b95678 Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Fri, 23 Aug 2024 11:44:27 +0200 Subject: [PATCH] - Initial release. --- .env | 11 +++++++++++ .gitignore | 2 ++ Dockerfile | 29 +++++++++++++++++++++++++++++ ReadMe.txt | 23 +++++++++++++++++++++++ ReleaseNotes.txt | 8 ++++++++ compose.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ run.sh | 16 ++++++++++++++++ sbin/user_add_exec | 42 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 171 insertions(+) create mode 100644 .env create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 ReadMe.txt create mode 100644 ReleaseNotes.txt create mode 100644 compose.yaml create mode 100755 run.sh create mode 100755 sbin/user_add_exec diff --git a/.env b/.env new file mode 100644 index 0000000..b79b3a0 --- /dev/null +++ b/.env @@ -0,0 +1,11 @@ +# Rx3 X11 Pulse Mageia-9 Docker Image +#------------------------------------------------------------------------------- + +IMG_NAME="x11-pulse-mga9" +IMG_FULL_NAME="Rx3 X11 Pulse Mageia-9 Docker Image" +IMG_VERSION="1.0.0" +IMG_MAINTAINER='"Arnaud G. GIBERT" ' + +# To be difines at run time +USER_ID="" +APPL_HOME_DIR="" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..556bc65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.old diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6d06aef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Rx3 X11 Pulse Mageia-9 Docker Image +#------------------------------------------------------------------------------- + +FROM docker.xor.rx3:5000/rx3/base-mga9:1.2.0 + +ARG IMG_NAME +ARG IMG_FULL_NAME +ARG IMG_VERSION +ARG IMG_MAINTAINER + +LABEL org.rx3.${IMG_NAME}.name=${IMG_FULL_NAME} +LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION} +LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER} +LABEL maintainer=${IMG_MAINTAINER} + + +ENV DISPLAY=:0 + + +RUN urpmi --force xterm lib64jack0 lib64opencl1 pipewire-media-session lib64proxy-webkit hunspell-en lib64xcb-xkb1 lib64xcomposite1 lib64xcursor1 lib64xdamage1 lib64xft-gir2.0 lib64xi6 lib64xinerama1 lib64xkbcommon0 lib64vulkan-loader1 lib64xlib-gir2.0 lib64xrandr2 lib64xmlb2 lib64xslt1 libexif12-common libgxps-tools frozen-bubble emacs + +COPY /sbin/user_add_exec /sbin + +VOLUME /home +VOLUME /tmp/.X11-unix/X0 +VOLUME /run/user + +CMD ["/bin/bash"] +ENTRYPOINT [] diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..11c4ba4 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,23 @@ +Welcome to X11-Pulse-Mga9 docker image! + + + +This is project aims to build a X11 + Pulse + Mageia-9 docker image able to run any graphic & audio application isolated. + +Features: + - Curtently based on base-mga9:1.2.0 image, + - X11 & Pulse base libraries installed, + - user_add_exec program to create on the run the user environement. + + +Usage: + ./run.sh + + +Enjoy it! + +Your Rx3 Team. + +-- +arnaud@rx3.net +https://git.rx3.org/gitea/rx3/x11-pulse-mga9 diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt new file mode 100644 index 0000000..ddca699 --- /dev/null +++ b/ReleaseNotes.txt @@ -0,0 +1,8 @@ +------------------------------------------------------------------------------------------------------------------------------------ +X11-Pulse-Mga9 V 1.0.0 - A. GIBERT - 2024/08/23 +------------------------------------------------------------------------------------------------------------------------------------ + +- Initial release, +- Use based on base-mga9:1.2.0 image, +- X11 & Pulse ready, +- user_add_exec installed. diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..50d1740 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,40 @@ +# Rx3 X11 Pulse Mageia-9 Docker Image +#------------------------------------------------------------------------------- + +name: ${IMG_NAME} + +services: + default: + container_name: ${IMG_NAME} + image: docker.xor.rx3:5000/rx3/${IMG_NAME}:${IMG_VERSION} + + build: + context: . + args: + - IMG_NAME=${IMG_NAME} + - IMG_FULL_NAME=${IMG_FULL_NAME} + - IMG_VERSION=${IMG_VERSION} + - IMG_MAINTAINER=${IMG_MAINTAINER} + + restart: unless-stopped + + environment: + - DISPLAY=:0 + + volumes: + - home_dir:/home + - type: bind + source: /tmp/.X11-unix/X0 + target: /tmp/.X11-unix/X0 + - type: bind + source: /run/user/${USER_ID}/pulse + target: /run/user/${USER_ID}/pulse + - type: bind + source: ${APPL_HOME_DIR} + target: ${APPL_HOME_DIR} + + network_mode: bridge + +volumes: + home_dir: + external: true diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..769e954 --- /dev/null +++ b/run.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +export APPL_HOME_DIR="$1" +shift + +export APPL_NAME="$1" +shift + + + +export USER_ID=$(id -u) +export GROUP_ID=$(id -g) +export GROUP_NAME=$(id -gn) + + +docker compose run --rm default /sbin/user_add_exec ${USER_ID} ${USER} ${HOME} ${GROUP_ID} ${GROUP_NAME} ${APPL_HOME_DIR}/${APPL_NAME} $* diff --git a/sbin/user_add_exec b/sbin/user_add_exec new file mode 100755 index 0000000..2bc3f2a --- /dev/null +++ b/sbin/user_add_exec @@ -0,0 +1,42 @@ +#!/bin/bash + +for arg in User_Id User_Name Home_Dir Group_Id Group_Name +do + declare "$arg"=$1 + shift +done + + + +echo "User Add & Exec: User_Id: (${User_Id}) User_Name: [${User_Name}] Home_Dir: [${Home_Dir}] Group_Id: (${Group_Id}) Group_Name: [${Group_Name}]" +echo " Display: [${DISPLAY}] Cmd: [${*}]" +echo "" + + +echo "Creating group..." + +groupadd --gid ${Group_Id} ${Group_Name} + + +echo "Creating user..." + +if [[ ! -d ${Home_Dir} ]] +then + home_opts="--create-home" +fi + +useradd 2>/dev/null --uid ${User_Id} --gid ${Group_Id} -m --home-dir ${Home_Dir} ${home_opts} --password "" ${User_Name} + + +echo "Update global profile..." + +echo -e "export DISPLAY=${DISPLAY}\nexport XDG_RUNTIME_DIR=/run/user/${User_Id}" >/etc/profile.d/x11.sh + +chown ${User_Name}:${Group_Name} /run/user/${User_Id} + + +echo "Exec Cmd..." + +su - -P ${User_Name} -c $* + +echo "Completed!"