Skip to content

Commit 890f9ca

Browse files
committed
feat: update Dockerfile and entrypoint scripts
- Updated Dockerfiles for Ubuntu 18.04, 20.04, and 22.04 to use Node.js version 16.x instead of 18.x or 20.x - Set environment variables LGSM_GITHUBBRANCH, LGSM_LOGDIR, LGSM_SERVERFILES, and LGSM_CONFIG to new values - Changed working directory from /linuxgsm to /app - Created /data directory in the container - Cleared modules directory (/app/lgsm/modules) if branch is not master
1 parent 3b437de commit 890f9ca

File tree

6 files changed

+97
-83
lines changed

6 files changed

+97
-83
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ansible.python.interpreterPath": "/bin/python3"
3+
}

Dockerfile.ubuntu-1804

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ ENV DEBIAN_FRONTEND noninteractive
1111
ENV TERM=xterm
1212
ENV LGSM_GITHUBUSER=GameServerManagers
1313
ENV LGSM_GITHUBREPO=LinuxGSM
14-
ENV LGSM_GITHUBBRANCH=develop
14+
ENV LGSM_GITHUBBRANCH=hotfix/v23.3.5
15+
ENV LGSM_LOGDIR=/data/log
16+
ENV LGSM_SERVERFILES=/data/serverfiles
17+
ENV LGSM_CONFIG=/data/config-lgsm
1518
ENV GAMESERVER=jc2server
1619
ENV UPDATE_CHECK=1800
1720
ENV USERNAME=linuxgsm
@@ -67,7 +70,7 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
6770

6871
# Install Node.js
6972
RUN echo "**** Install Node.js ****" \
70-
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \
73+
&& curl -sL https://deb.nodesource.com/setup_16.x | bash - \
7174
&& apt-get update \
7275
&& apt-get install -y nodejs \
7376
&& apt-get -y autoremove \
@@ -80,43 +83,47 @@ RUN echo "**** Install Node.js ****" \
8083
RUN echo "**** Install GameDig ****" \
8184
&& npm install -g gamedig
8285

83-
WORKDIR /linuxgsm
86+
WORKDIR /app
8487

8588
## Add linuxgsm user
8689
RUN echo "**** Add linuxgsm user ****" \
90+
&& mkdir /data \
8791
# Create the user
8892
&& groupadd --gid $GID $USERNAME \
8993
&& useradd --uid $UID --gid $GID -m $USERNAME \
9094
#
9195
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
9296
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
9397
&& chmod 0440 /etc/sudoers.d/$USERNAME \
94-
&& chown $USERNAME:$USERNAME /home/$USERNAME
98+
&& chown $USERNAME:$USERNAME /data
9599

96-
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/entrypoint-healthcheck.sh || exit 1
100+
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1
97101

98102
## Download linuxgsm.sh
99103
RUN echo "**** Download linuxgsm.sh ****" \
100104
&& set -ex \
101-
&& mkdir -p /linuxgsm/lgsm \
102105
&& wget -O linuxgsm.sh "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/${LGSM_GITHUBBRANCH}/linuxgsm.sh" \
103106
&& chmod +x linuxgsm.sh
104107

105108
RUN echo "**** Get LinuxGSM Modules ****" \
106109
&& git clone --filter=blob:none --no-checkout --sparse https://github.com/GameServerManagers/LinuxGSM.git \
107110
&& cd LinuxGSM \
108111
&& git sparse-checkout set --cone \
109-
&& git sparse-checkout set lgsm/functions \
112+
&& git sparse-checkout set lgsm/modules \
110113
&& git checkout ${LGSM_GITHUBBRANCH} \
111-
&& mkdir -p /linuxgsm/lgsm/functions \
112-
&& mv lgsm/functions/* /linuxgsm/lgsm/functions \
113-
&& chmod +x /linuxgsm/lgsm/functions/* \
114-
&& rm -rf /linuxgsm/LinuxGSM \
115-
&& chown -R $USERNAME:$USERNAME /linuxgsm
114+
&& mkdir -p /app/lgsm/modules \
115+
&& mv lgsm/modules/* /app/lgsm/modules \
116+
&& chmod +x /app/lgsm/modules/* \
117+
&& cd ../ \
118+
&& rm -rf LinuxGSM \
119+
&& chown -R $USERNAME:$USERNAME /app
116120

117-
COPY entrypoint.sh /linuxgsm/entrypoint.sh
118-
COPY entrypoint-user.sh /linuxgsm/entrypoint-user.sh
119-
COPY entrypoint-healthcheck.sh /linuxgsm/entrypoint-healthcheck.sh
121+
ARG CACHEBUST=1
122+
RUN echo "$CACHEBUST"
123+
124+
COPY entrypoint.sh /app/entrypoint.sh
125+
COPY entrypoint-user.sh /app/entrypoint-user.sh
126+
COPY entrypoint-healthcheck.sh /app/entrypoint-healthcheck.sh
120127

121128
RUN date > /build-time.txt
122129

Dockerfile.ubuntu-2004

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ ENV DEBIAN_FRONTEND noninteractive
1111
ENV TERM=xterm
1212
ENV LGSM_GITHUBUSER=GameServerManagers
1313
ENV LGSM_GITHUBREPO=LinuxGSM
14-
ENV LGSM_GITHUBBRANCH=develop
14+
ENV LGSM_GITHUBBRANCH=hotfix/v23.3.5
15+
ENV LGSM_LOGDIR=/data/log
16+
ENV LGSM_SERVERFILES=/data/serverfiles
17+
ENV LGSM_CONFIG=/data/config-lgsm
1518
ENV GAMESERVER=jc2server
1619
ENV UPDATE_CHECK=1800
1720
ENV USERNAME=linuxgsm
@@ -67,7 +70,7 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
6770

6871
# Install Node.js
6972
RUN echo "**** Install Node.js ****" \
70-
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \
73+
&& curl -sL https://deb.nodesource.com/setup_20.x | bash - \
7174
&& apt-get update \
7275
&& apt-get install -y nodejs \
7376
&& apt-get -y autoremove \
@@ -80,43 +83,47 @@ RUN echo "**** Install Node.js ****" \
8083
RUN echo "**** Install GameDig ****" \
8184
&& npm install -g gamedig
8285

83-
WORKDIR /linuxgsm
86+
WORKDIR /app
8487

8588
## Add linuxgsm user
8689
RUN echo "**** Add linuxgsm user ****" \
90+
&& mkdir /data \
8791
# Create the user
8892
&& groupadd --gid $GID $USERNAME \
8993
&& useradd --uid $UID --gid $GID -m $USERNAME \
9094
#
9195
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
9296
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
9397
&& chmod 0440 /etc/sudoers.d/$USERNAME \
94-
&& chown $USERNAME:$USERNAME /home/$USERNAME
98+
&& chown $USERNAME:$USERNAME /data
9599

96-
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/entrypoint-healthcheck.sh || exit 1
100+
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1
97101

98102
## Download linuxgsm.sh
99103
RUN echo "**** Download linuxgsm.sh ****" \
100104
&& set -ex \
101-
&& mkdir -p /linuxgsm/lgsm \
102105
&& wget -O linuxgsm.sh "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/${LGSM_GITHUBBRANCH}/linuxgsm.sh" \
103106
&& chmod +x linuxgsm.sh
104107

105108
RUN echo "**** Get LinuxGSM Modules ****" \
106109
&& git clone --filter=blob:none --no-checkout --sparse https://github.com/GameServerManagers/LinuxGSM.git \
107110
&& cd LinuxGSM \
108111
&& git sparse-checkout set --cone \
109-
&& git sparse-checkout set lgsm/functions \
112+
&& git sparse-checkout set lgsm/modules \
110113
&& git checkout ${LGSM_GITHUBBRANCH} \
111-
&& mkdir -p /linuxgsm/lgsm/functions \
112-
&& mv lgsm/functions/* /linuxgsm/lgsm/functions \
113-
&& chmod +x /linuxgsm/lgsm/functions/* \
114-
&& rm -rf /linuxgsm/LinuxGSM \
115-
&& chown -R $USERNAME:$USERNAME /linuxgsm
114+
&& mkdir -p /app/lgsm/modules \
115+
&& mv lgsm/modules/* /app/lgsm/modules \
116+
&& chmod +x /app/lgsm/modules/* \
117+
&& cd ../ \
118+
&& rm -rf LinuxGSM \
119+
&& chown -R $USERNAME:$USERNAME /app
116120

117-
COPY entrypoint.sh /linuxgsm/entrypoint.sh
118-
COPY entrypoint-user.sh /linuxgsm/entrypoint-user.sh
119-
COPY entrypoint-healthcheck.sh /linuxgsm/entrypoint-healthcheck.sh
121+
ARG CACHEBUST=1
122+
RUN echo "$CACHEBUST"
123+
124+
COPY entrypoint.sh /app/entrypoint.sh
125+
COPY entrypoint-user.sh /app/entrypoint-user.sh
126+
COPY entrypoint-healthcheck.sh /app/entrypoint-healthcheck.sh
120127

121128
RUN date > /build-time.txt
122129

Dockerfile.ubuntu-2204

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ ENV DEBIAN_FRONTEND noninteractive
1111
ENV TERM=xterm
1212
ENV LGSM_GITHUBUSER=GameServerManagers
1313
ENV LGSM_GITHUBREPO=LinuxGSM
14-
ENV LGSM_GITHUBBRANCH=develop
14+
ENV LGSM_GITHUBBRANCH=hotfix/v23.3.5
15+
ENV LGSM_LOGDIR=/data/log
16+
ENV LGSM_SERVERFILES=/data/serverfiles
17+
ENV LGSM_CONFIG=/data/config-lgsm
1518
ENV GAMESERVER=jc2server
1619
ENV UPDATE_CHECK=1800
1720
ENV USERNAME=linuxgsm
@@ -67,7 +70,7 @@ RUN echo "**** Install Base LinuxGSM Requirements ****" \
6770

6871
# Install Node.js
6972
RUN echo "**** Install Node.js ****" \
70-
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \
73+
&& curl -sL https://deb.nodesource.com/setup_20.x | bash - \
7174
&& apt-get update \
7275
&& apt-get install -y nodejs \
7376
&& apt-get -y autoremove \
@@ -80,25 +83,25 @@ RUN echo "**** Install Node.js ****" \
8083
RUN echo "**** Install GameDig ****" \
8184
&& npm install -g gamedig
8285

83-
WORKDIR /linuxgsm
86+
WORKDIR /app
8487

8588
## Add linuxgsm user
8689
RUN echo "**** Add linuxgsm user ****" \
90+
&& mkdir /data \
8791
# Create the user
8892
&& groupadd --gid $GID $USERNAME \
8993
&& useradd --uid $UID --gid $GID -m $USERNAME \
9094
#
9195
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
9296
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
9397
&& chmod 0440 /etc/sudoers.d/$USERNAME \
94-
&& chown $USERNAME:$USERNAME /home/$USERNAME
98+
&& chown $USERNAME:$USERNAME /data
9599

96-
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /linuxgsm/entrypoint-healthcheck.sh || exit 1
100+
HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1
97101

98102
## Download linuxgsm.sh
99103
RUN echo "**** Download linuxgsm.sh ****" \
100104
&& set -ex \
101-
&& mkdir -p /linuxgsm/lgsm \
102105
&& wget -O linuxgsm.sh "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/${LGSM_GITHUBBRANCH}/linuxgsm.sh" \
103106
&& chmod +x linuxgsm.sh
104107

@@ -108,18 +111,19 @@ RUN echo "**** Get LinuxGSM Modules ****" \
108111
&& git sparse-checkout set --cone \
109112
&& git sparse-checkout set lgsm/modules \
110113
&& git checkout ${LGSM_GITHUBBRANCH} \
111-
&& mkdir -p /linuxgsm/lgsm/modules \
112-
&& mv lgsm/modules/* /linuxgsm/lgsm/modules \
113-
&& chmod +x /linuxgsm/lgsm/modules/* \
114-
&& rm -rf /linuxgsm/LinuxGSM \
115-
&& chown -R $USERNAME:$USERNAME /linuxgsm
114+
&& mkdir -p /app/lgsm/modules \
115+
&& mv lgsm/modules/* /app/lgsm/modules \
116+
&& chmod +x /app/lgsm/modules/* \
117+
&& cd ../ \
118+
&& rm -rf LinuxGSM \
119+
&& chown -R $USERNAME:$USERNAME /app
116120

117121
ARG CACHEBUST=1
118122
RUN echo "$CACHEBUST"
119123

120-
COPY entrypoint.sh /linuxgsm/entrypoint.sh
121-
COPY entrypoint-user.sh /linuxgsm/entrypoint-user.sh
122-
COPY entrypoint-healthcheck.sh /linuxgsm/entrypoint-healthcheck.sh
124+
COPY entrypoint.sh /app/entrypoint.sh
125+
COPY entrypoint-user.sh /app/entrypoint-user.sh
126+
COPY entrypoint-healthcheck.sh /app/entrypoint-healthcheck.sh
123127

124128
RUN date > /build-time.txt
125129

entrypoint-user.sh

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,58 @@ if [ ! -f "${GAMESERVER}" ]; then
44
echo -e ""
55
echo -e "creating ${GAMESERVER}"
66
echo -e "================================="
7-
./linuxgsm.sh ${GAMESERVER}
7+
./linuxgsm.sh "${GAMESERVER}"
88
fi
99

10-
# Clear functions directory if not master
10+
# Clear modules directory if not master
1111
if [ "${LGSM_GITHUBBRANCH}" != "master" ]; then
12-
echo -e "not master branch, clearing functions directory"
13-
rm -rf /linuxgsm/lgsm/modules/*
14-
elif [ -d "/linuxgsm/lgsm/modules" ]; then
15-
echo -e "ensure all functions are executable"
16-
chmod +x /linuxgsm/lgsm/modules/*
12+
echo -e "not master branch, clearing modules directory"
13+
rm -rf /app/lgsm/modules/*
14+
elif [ -d "/app/lgsm/modules" ]; then
15+
echo -e "ensure all modules are executable"
16+
chmod +x /app/lgsm/modules/*
1717
fi
1818

1919
# Install game server
2020
if [ -z "$(ls -A -- "serverfiles" 2> /dev/null)" ]; then
2121
echo -e ""
2222
echo -e "Installing ${GAMESERVER}"
2323
echo -e "================================="
24-
./${GAMESERVER} auto-install
24+
./"${GAMESERVER}" auto-install
2525
install=1
2626
else
27-
# Donate to display logo
28-
./${GAMESERVER} sponsor
27+
# Sponsor to display LinuxGSM logo
28+
./"${GAMESERVER}" sponsor
2929
fi
3030
echo -e ""
3131
echo -e "Starting Update Checks"
3232
echo -e "================================="
33-
nohup watch -n "${UPDATE_CHECK}" ./${GAMESERVER} update > /dev/null 2>&1 &
33+
nohup watch -n "${UPDATE_CHECK}" ./"${GAMESERVER}" update > /dev/null 2>&1 &
3434
echo -e "update will check every ${UPDATE_CHECK} minutes"
3535

3636
# Update game server
3737
if [ -z "${install}" ]; then
3838
echo -e ""
3939
echo -e "Checking for Update ${GAMESERVER}"
4040
echo -e "================================="
41-
./${GAMESERVER} update
41+
./"${GAMESERVER}" update
4242
fi
4343

4444
echo -e ""
4545
echo -e "Starting ${GAMESERVER}"
4646
echo -e "================================="
47-
./${GAMESERVER} start
47+
./"${GAMESERVER}" start
4848
sleep 5
49-
./${GAMESERVER} details
49+
./"${GAMESERVER}" details
5050
sleep 2
5151
echo -e "Tail log files"
5252
echo -e "================================="
53-
tail -F log/*/*.log
5453

55-
# with no command, just spawn a running container suitable for exec's
56-
if [ $# = 0 ]; then
57-
tail -f /dev/null
54+
echo "DOLLAR0 $0"
55+
echo "DOLLAR1 $1"
56+
if [ -n "$1" ]; then
57+
exec "$@"
5858
else
59-
# execute the command passed through docker
60-
"$@"
61-
62-
# if this command was a server start cmd
63-
# to get around LinuxGSM running everything in
64-
# tmux;
65-
# we attempt to attach to tmux to track the server
66-
# this keeps the container running
67-
# when invoked via docker run
68-
# but requires -it or at least -t
69-
tmux set -g status off && tmux attach 2> /dev/null
59+
tail -F log/*/*.log
7060
fi
71-
7261
exec "$@"

entrypoint.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exit_handler() {
44
# Execute the shutdown commands
55
echo -e "stopping ${GAMESERVER}"
6-
exec gosu ${USERNAME} ./${GAMESERVER} stop
6+
exec gosu "${USERNAME}" ./${GAMESERVER} stop
77
exitcode=$?
88
exit ${exitcode}
99
}
@@ -27,6 +27,9 @@ echo -e ""
2727
echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}"
2828
echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}"
2929
echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}"
30+
echo -e "LGSM_LOGDIR: ${LGSM_LOGDIR}"
31+
echo -e "LGSM_SERVERFILES: ${LGSM_SERVERFILES}"
32+
echo -e "LGSM_CONFIG: ${LGSM_CONFIG}"
3033

3134
echo -e ""
3235
echo -e "Initalising"
@@ -35,23 +38,24 @@ echo -e "=======================================================================
3538
export LGSM_GITHUBUSER=${LGSM_GITHUBUSER}
3639
export LGSM_GITHUBREPO=${LGSM_GITHUBREPO}
3740
export LGSM_GITHUBBRANCH=${LGSM_GITHUBBRANCH}
41+
export LGSM_LOGDIR=${LGSM_LOGDIR}
42+
export LGSM_SERVERFILES=${LGSM_SERVERFILES}
43+
export LGSM_CONFIG=${LGSM_CONFIG}
3844

39-
cd /linuxgsm || exit
45+
cd /app || exit
4046

4147
echo -e ""
4248
echo -e "Check Permissions"
4349
echo -e "================================="
4450
echo -e "setting UID to ${UID}"
45-
usermod -u ${UID} -m -d /linuxgsm linuxgsm > /dev/null 2>&1
51+
usermod -u "${UID}" -m -d /data linuxgsm > /dev/null 2>&1
4652
echo -e "setting GID to ${GID}"
47-
groupmod -g ${GID} linuxgsm
53+
groupmod -g "${GID}" linuxgsm
4854
echo -e "updating permissions"
49-
find /linuxgsm -user ${UID} -exec chown -h linuxgsm {} \;
50-
find /linuxgsm -group ${GID} -exec chgrp -h linuxgsm {} \;
51-
chown -R ${USERNAME}:${USERNAME} /linuxgsm
52-
export HOME=/home/linuxgsm
55+
chown -R "${USERNAME}":"${USERNAME}" /data
56+
export HOME=/data
5357

5458
echo -e ""
5559
echo -e "Switch to user ${USERNAME}"
5660
echo -e "================================="
57-
exec gosu ${USERNAME} /linuxgsm/entrypoint-user.sh
61+
exec gosu "${USERNAME}" /app/entrypoint-user.sh

0 commit comments

Comments
 (0)