Browse Source

feat: migrate to s6-overlay for init

pull/6/head
Daniel Gibbs 2 years ago
parent
commit
3b2e2a1d91
No known key found for this signature in database GPG Key ID: 4D812BAB6228BBA6
  1. 50
      Dockerfile.ubuntu-1804
  2. 49
      Dockerfile.ubuntu-2004
  3. 47
      Dockerfile.ubuntu-2204
  4. 35
      entrypoint.sh

50
Dockerfile.ubuntu-1804

@ -7,11 +7,18 @@
FROM gameservermanagers/steamcmd:ubuntu-18.04
LABEL maintainer="LinuxGSM <[email protected]>"
ARG S6_OVERLAY_VERSION=3.1.2.1
ARG OVERLAY_ARCH="amd64"
ENV DEBIAN_FRONTEND noninteractive
ENV TERM=xterm
ENV LGSM_GITHUBUSER=GameServerManagers
ENV LGSM_GITHUBREPO=LinuxGSM
ENV LGSM_GITHUBBRANCH=develop
ENV GAMESERVER=jc3server
ENV UPDATE_CHECK=1800
ENV USERNAME=linuxgsm
ENV UID=1000
ENV GID=1000
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
## Install Base LinuxGSM Requirements
@ -20,7 +27,6 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
&& apt-get install -y software-properties-common \
&& add-apt-repository multiverse \
&& add-apt-repository ppa:git-core/ppa \
&& add-apt-repository ppa:jfhovinne/bionic-testing \
&& apt-get update \
&& apt-get install -y \
cron \
@ -37,13 +43,12 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
gzip \
hostname \
jq \
lib32gcc1 \
lib32gcc-s1 \
lib32stdc++6 \
netcat \
python3 \
sudo \
tar \
tini \
tmux \
unzip \
util-linux \
@ -75,8 +80,37 @@ RUN echo "**** Install Node.js ****" \
RUN echo "**** Install GameDig ****" \
&& npm install -g gamedig
# Install s6 overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz
RUN date > /build-time.txt
WORKDIR /linuxgsm
COPY entrypoint.sh /linuxgsm/entrypoint.sh
## Add linuxgsm user
RUN echo "**** Add linuxgsm user ****" \
# Create the user
&& groupadd --gid $GID $USERNAME \
&& useradd --uid $UID --gid $GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown $USERNAME:$USERNAME /home/$USERNAME \
&& chown -R $USERNAME:$USERNAME /linuxgsm
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/*server monitor || exit 1
USER linuxgsm
## Download linuxgsm.sh
RUN echo "**** Download linuxgsm.sh ****" \
&& set -ex \
@ -99,11 +133,5 @@ RUN echo "**** Get LinuxGSM Modules ****" \
RUN echo "**** Create Cronjob ****"
RUN (crontab -l 2>/dev/null; echo "*/30 * * * * /linuxgsm/*server update > /dev/null 2>&1") | crontab -
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/*server monitor || exit 1
RUN rm -f /linuxgsm/entrypoint.sh
COPY entrypoint.sh /linuxgsm/entrypoint.sh
RUN date > /time.txt
ENTRYPOINT [ "/usr/bin/tini","-g","--" ]
CMD [ "bash","./entrypoint.sh" ]
ENTRYPOINT ["/init"]
CMD [ "./entrypoint.sh" ]

49
Dockerfile.ubuntu-2004

@ -7,11 +7,18 @@
FROM gameservermanagers/steamcmd:ubuntu-20.04
LABEL maintainer="LinuxGSM <[email protected]>"
ARG S6_OVERLAY_VERSION=3.1.2.1
ARG OVERLAY_ARCH="amd64"
ENV DEBIAN_FRONTEND noninteractive
ENV TERM=xterm
ENV LGSM_GITHUBUSER=GameServerManagers
ENV LGSM_GITHUBREPO=LinuxGSM
ENV LGSM_GITHUBBRANCH=develop
ENV GAMESERVER=jc3server
ENV UPDATE_CHECK=1800
ENV USERNAME=linuxgsm
ENV UID=1000
ENV GID=1000
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
## Install Base LinuxGSM Requirements
@ -36,13 +43,12 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
gzip \
hostname \
jq \
lib32gcc1 \
lib32gcc-s1 \
lib32stdc++6 \
netcat \
python3 \
sudo \
tar \
tini \
tmux \
unzip \
util-linux \
@ -74,8 +80,37 @@ RUN echo "**** Install Node.js ****" \
RUN echo "**** Install GameDig ****" \
&& npm install -g gamedig
# Install s6 overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz
RUN date > /build-time.txt
WORKDIR /linuxgsm
COPY entrypoint.sh /linuxgsm/entrypoint.sh
## Add linuxgsm user
RUN echo "**** Add linuxgsm user ****" \
# Create the user
&& groupadd --gid $GID $USERNAME \
&& useradd --uid $UID --gid $GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown $USERNAME:$USERNAME /home/$USERNAME \
&& chown -R $USERNAME:$USERNAME /linuxgsm
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/*server monitor || exit 1
USER linuxgsm
## Download linuxgsm.sh
RUN echo "**** Download linuxgsm.sh ****" \
&& set -ex \
@ -98,11 +133,5 @@ RUN echo "**** Get LinuxGSM Modules ****" \
RUN echo "**** Create Cronjob ****"
RUN (crontab -l 2>/dev/null; echo "*/30 * * * * /linuxgsm/*server update > /dev/null 2>&1") | crontab -
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/*server monitor || exit 1
RUN rm -f /linuxgsm/entrypoint.sh
COPY entrypoint.sh /linuxgsm/entrypoint.sh
RUN date > /time.txt
ENTRYPOINT [ "/usr/bin/tini","-g","--" ]
CMD [ "bash","./entrypoint.sh" ]
ENTRYPOINT ["/init"]
CMD [ "./entrypoint.sh" ]

47
Dockerfile.ubuntu-2204

@ -7,11 +7,18 @@
FROM gameservermanagers/steamcmd:ubuntu-22.04
LABEL maintainer="LinuxGSM <[email protected]>"
ARG S6_OVERLAY_VERSION=3.1.2.1
ARG OVERLAY_ARCH="amd64"
ENV DEBIAN_FRONTEND noninteractive
ENV TERM=xterm
ENV LGSM_GITHUBUSER=GameServerManagers
ENV LGSM_GITHUBREPO=LinuxGSM
ENV LGSM_GITHUBBRANCH=develop
ENV GAMESERVER=jc3server
ENV UPDATE_CHECK=1800
ENV USERNAME=linuxgsm
ENV UID=1000
ENV GID=1000
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
## Install Base LinuxGSM Requirements
@ -42,7 +49,6 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
python3 \
sudo \
tar \
tini \
tmux \
unzip \
util-linux \
@ -74,8 +80,37 @@ RUN echo "**** Install Node.js ****" \
RUN echo "**** Install GameDig ****" \
&& npm install -g gamedig
# Install s6 overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz
RUN date > /build-time.txt
WORKDIR /linuxgsm
COPY entrypoint.sh /linuxgsm/entrypoint.sh
## Add linuxgsm user
RUN echo "**** Add linuxgsm user ****" \
# Create the user
&& groupadd --gid $GID $USERNAME \
&& useradd --uid $UID --gid $GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown $USERNAME:$USERNAME /home/$USERNAME \
&& chown -R $USERNAME:$USERNAME /linuxgsm
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/*server monitor || exit 1
USER linuxgsm
## Download linuxgsm.sh
RUN echo "**** Download linuxgsm.sh ****" \
&& set -ex \
@ -98,11 +133,5 @@ RUN echo "**** Get LinuxGSM Modules ****" \
RUN echo "**** Create Cronjob ****"
RUN (crontab -l 2>/dev/null; echo "*/30 * * * * /linuxgsm/*server update > /dev/null 2>&1") | crontab -
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/*server monitor || exit 1
RUN rm -f /linuxgsm/entrypoint.sh
COPY entrypoint.sh /linuxgsm/entrypoint.sh
RUN date > /time.txt
ENTRYPOINT [ "/usr/bin/tini","-g","--" ]
CMD [ "bash","./entrypoint.sh" ]
ENTRYPOINT ["/init"]
CMD [ "./entrypoint.sh" ]

35
entrypoint.sh

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/with-contenv bash
exit_handler() {
# Execute the shutdown commands
@ -15,8 +15,8 @@ trap exit_handler SIGQUIT SIGINT SIGTERM
echo -e ""
echo -e "Welcome to the LinuxGSM"
echo -e "================================================================================"
echo -e "TIME: $(date)"
echo -e "SCRIPT TIME: $(cat /time.txt)"
echo -e "CURRENT TIME: $(date)"
echo -e "BUILD TIME: $(cat /build-time.txt)"
echo -e "GAMESERVER: ${GAMESERVER}"
echo -e ""
echo -e "USER: ${USERNAME}"
@ -37,6 +37,9 @@ export LGSM_GITHUBBRANCH=${LGSM_GITHUBBRANCH}
cd /linuxgsm || exit
# permissions
chown -R linuxgsm:linuxgsm /linuxgsm
# Setup game server
if [ ! -f "${GAMESERVER}" ]; then
echo -e ""
@ -44,15 +47,15 @@ if [ ! -f "${GAMESERVER}" ]; then
./linuxgsm.sh ${GAMESERVER}
fi
if [ -d "/linuxgsm/lgsm/functions" ]; then
echo -e ""
echo -e "check all functions are executable"
chmod +x /linuxgsm/lgsm/functions/*
fi
# Clear functions directory if not master
if [ "${LGSM_GITHUBBRANCH}" != "master" ]; then
echo -e ""
echo -e "not master branch, clearing functions directory"
rm -rf /linuxgsm/lgsm/functions/*
elif [ -d "/linuxgsm/lgsm/functions" ]; then
echo -e ""
echo -e "check all functions are executable"
chmod +x /linuxgsm/lgsm/functions/*
fi
# Install game server
@ -61,6 +64,7 @@ if [ -z "$(ls -A -- "serverfiles")" ]; then
echo -e "Installing ${GAMESERVER}"
echo -e "================================="
./${GAMESERVER} auto-install
install=1
else
# Donate to display logo
./${GAMESERVER} donate
@ -68,13 +72,16 @@ fi
echo -e "Starting cron"
echo -e "================================="
cron
#cron
nohup watch -n "${UPDATE_CHECK}" ./${GAMESERVER} update >/dev/null 2>&1 &
# Update game server
echo -e ""
echo -e "Updating ${GAMESERVER}"
echo -e "================================="
./${GAMESERVER} update
if [ -z "${install}" ]; then
echo -e ""
echo -e "Updating ${GAMESERVER}"
echo -e "================================="
./${GAMESERVER} update
fi
echo -e ""
echo -e "Starting ${GAMESERVER}"

Loading…
Cancel
Save