From 6a0f5a7e1dd8c597b39f98ca3451a0778434b48b Mon Sep 17 00:00:00 2001 From: Giuseppe C Date: Sat, 15 Feb 2020 18:35:16 +0100 Subject: [PATCH 1/4] let docker do what tmux used to. and add a docker-compose.yml for testing purposes --- Dockerfile | 30 ++++++++---------------------- docker-compose.yml | 6 ++++++ entrypoint.sh | 22 ++++++++-------------- 3 files changed, 22 insertions(+), 36 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 4c94e38..56e128a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,9 @@ ENV LANG en_US.utf8 ## Base System RUN dpkg --add-architecture i386 && \ - apt update -y && \ - apt install -y \ + apt-get update -y && \ + apt-get install -y \ + iproute2\ mailutils \ postfix \ curl \ @@ -66,36 +67,21 @@ RUN dpkg --add-architecture i386 && \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -# Add the linuxgsm user -RUN adduser \ - --disabled-login \ - --disabled-password \ - --shell /bin/bash \ - --gecos "" \ - linuxgsm \ - && usermod -G tty linuxgsm \ - && chown -R linuxgsm:linuxgsm /home/linuxgsm - -# Switch to the user linuxgsm -USER linuxgsm - - -## linuxgsm.sh -RUN wget https://linuxgsm.com/dl/linuxgsm.sh ## user config RUN groupadd -g 750 -o linuxgsm && \ adduser --uid 750 --disabled-password --gecos "" --ingroup linuxgsm linuxgsm && \ - chown linuxgsm:linuxgsm /linuxgsm.sh && \ - chmod +x /linuxgsm.sh && \ - cp /linuxgsm.sh /home/linuxgsm/linuxgsm.sh && \ usermod -G tty linuxgsm && \ chown -R linuxgsm:linuxgsm /home/linuxgsm/ && \ chmod 755 /home/linuxgsm +# Switch to the user linuxgsm USER linuxgsm WORKDIR /home/linuxgsm -VOLUME [ "/home/linuxgsm" ] + +## linuxgsm.sh +RUN wget https://linuxgsm.com/dl/linuxgsm.sh -O ~/linuxgsm.sh && chmod +x ~/linuxgsm.sh +VOLUME [ "/home/linuxgsm" ] # define volume _after_ download. # need use xterm for LinuxGSM ENV TERM=xterm diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dc523eb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: '3.3' +services: + quake2: + build: . + environment: + - GAMESERVER=q2server diff --git a/entrypoint.sh b/entrypoint.sh index b48d25b..b830c7f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,24 +11,18 @@ ## then we must keep a backup copy of the script on local drive if [ ! -e ~/linuxgsm.sh ]; then echo "Initializing Linuxgsm User Script in New Volume" - cp /linuxgsm.sh ./linuxgsm.sh + wget https://linuxgsm.com/dl/linuxgsm.sh -O ~/linuxgsm.sh && chmod +x ~/linuxgsm.sh fi -# with no command, just spawn a running container suitable for exec's +# with no command, just run the game (or try) if [ $# = 0 ]; then - tail -f /dev/null + if [ ! -e "$GAMESERVER" ]; then + echo "Installing $GAMESERVER" + ./linuxgsm.sh $GAMESERVER && ./$GAMESERVER auto-install + fi + echo "Launching $GAMESERVER (IN DEBUG MODE)" + echo Y | ./$GAMESERVER debug else # execute the command passed through docker "$@" - - # if this command was a server start cmd - # to get around LinuxGSM running everything in - # tmux; - # we attempt to attach to tmux to track the server - # this keeps the container running - # when invoked via docker run - # but requires -it or at least -t - tmux set -g status off && tmux attach 2> /dev/null fi - -exit 0 \ No newline at end of file From 04670eed6daf3a1292b8a0d18fba084fb1645018 Mon Sep 17 00:00:00 2001 From: Giuseppe C Date: Sun, 16 Feb 2020 16:10:18 +0100 Subject: [PATCH 2/4] quote variables --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b830c7f..bda65be 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,10 +18,10 @@ fi if [ $# = 0 ]; then if [ ! -e "$GAMESERVER" ]; then echo "Installing $GAMESERVER" - ./linuxgsm.sh $GAMESERVER && ./$GAMESERVER auto-install + ./linuxgsm.sh "$GAMESERVER" && "./$GAMESERVER" auto-install fi echo "Launching $GAMESERVER (IN DEBUG MODE)" - echo Y | ./$GAMESERVER debug + echo Y | "./$GAMESERVER" debug else # execute the command passed through docker "$@" From 5f59e967b7b39304ce51cd87ffe026ca517838db Mon Sep 17 00:00:00 2001 From: Giuseppe C Date: Sun, 16 Feb 2020 22:09:49 +0100 Subject: [PATCH 3/4] improve readability --- Dockerfile | 124 +++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56e128a..945a8e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,78 +9,82 @@ LABEL maintainer="LinuxGSM " ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ - && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +RUN apt-get update \ + && apt-get install -y locales \ + && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 + ENV LANG en_US.utf8 ## Base System -RUN dpkg --add-architecture i386 && \ - apt-get update -y && \ - apt-get install -y \ - iproute2\ - mailutils \ - postfix \ - curl \ - wget \ - file \ - bzip2 \ - gzip \ - unzip \ - bsdmainutils \ - python \ - util-linux \ - binutils \ - bc \ - jq \ - tmux \ - lib32gcc1 \ - libstdc++6 \ - libstdc++6:i386 \ - apt-transport-https \ - ca-certificates \ - telnet \ - expect \ - libncurses5:i386 \ - libcurl4-gnutls-dev:i386 \ - libstdc++5:i386 \ - lib32tinfo5 \ - xz-utils \ - zlib1g:i386 \ - libldap-2.4-2:i386 \ - lib32z1 \ - default-jre \ - speex:i386 \ - libtbb2 \ - libxrandr2:i386 \ - libglu1-mesa:i386 \ - libxtst6:i386 \ - libusb-1.0-0:i386 \ - libopenal1:i386 \ - libpulse0:i386 \ - libdbus-glib-1-2:i386 \ - libnm-glib4:i386 \ - zlib1g \ - libssl1.0.0:i386 \ - libtcmalloc-minimal4:i386 \ - libsdl1.2debian \ - libnm-glib-dev:i386 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +RUN dpkg --add-architecture i386 \ + && apt-get update -y \ + && apt-get install -y iproute2\ + mailutils \ + postfix \ + curl \ + wget \ + file \ + bzip2 \ + gzip \ + unzip \ + bsdmainutils \ + python \ + util-linux \ + binutils \ + bc \ + jq \ + tmux \ + lib32gcc1 \ + libstdc++6 \ + libstdc++6:i386 \ + apt-transport-https \ + ca-certificates \ + telnet \ + expect \ + libncurses5:i386 \ + libcurl4-gnutls-dev:i386 \ + libstdc++5:i386 \ + lib32tinfo5 \ + xz-utils \ + zlib1g:i386 \ + libldap-2.4-2:i386 \ + lib32z1 \ + default-jre \ + speex:i386 \ + libtbb2 \ + libxrandr2:i386 \ + libglu1-mesa:i386 \ + libxtst6:i386 \ + libusb-1.0-0:i386 \ + libopenal1:i386 \ + libpulse0:i386 \ + libdbus-glib-1-2:i386 \ + libnm-glib4:i386 \ + zlib1g \ + libssl1.0.0:i386 \ + libtcmalloc-minimal4:i386 \ + libsdl1.2debian \ + libnm-glib-dev:i386 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* ## user config -RUN groupadd -g 750 -o linuxgsm && \ - adduser --uid 750 --disabled-password --gecos "" --ingroup linuxgsm linuxgsm && \ - usermod -G tty linuxgsm && \ - chown -R linuxgsm:linuxgsm /home/linuxgsm/ && \ - chmod 755 /home/linuxgsm +RUN groupadd -g 750 -o linuxgsm \ + && adduser --uid 750 --disabled-password --gecos "" --ingroup linuxgsm linuxgsm \ + && usermod -G tty linuxgsm \ + && chown -R linuxgsm:linuxgsm /home/linuxgsm/ \ + && chmod 755 /home/linuxgsm # Switch to the user linuxgsm USER linuxgsm WORKDIR /home/linuxgsm ## linuxgsm.sh -RUN wget https://linuxgsm.com/dl/linuxgsm.sh -O ~/linuxgsm.sh && chmod +x ~/linuxgsm.sh +RUN wget https://linuxgsm.com/dl/linuxgsm.sh -O ~/linuxgsm.sh \ + && chmod +x ~/linuxgsm.sh + VOLUME [ "/home/linuxgsm" ] # define volume _after_ download. # need use xterm for LinuxGSM From d96c6fd94975c9c1bdb1166232192e5af0ebc593 Mon Sep 17 00:00:00 2001 From: Giuseppe C Date: Mon, 17 Feb 2020 00:43:35 +0100 Subject: [PATCH 4/4] satisfy codacybot with --no-install-recommends --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 945a8e5..3054c61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ LABEL maintainer="LinuxGSM " ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ - && apt-get install -y locales \ + && apt-get install --no-install-recommends -y locales \ && rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 @@ -19,7 +19,8 @@ ENV LANG en_US.utf8 ## Base System RUN dpkg --add-architecture i386 \ && apt-get update -y \ - && apt-get install -y iproute2\ + && apt-get install -y --no-install-recommends\ + iproute2\ mailutils \ postfix \ curl \