improve image to reduce size
This commit is contained in:
45
Dockerfile
45
Dockerfile
@ -1,29 +1,40 @@
|
|||||||
|
# Create builder image
|
||||||
|
FROM debian:bookworm-slim AS builder
|
||||||
|
|
||||||
|
ARG VERSION="Latest"
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
apt install -y --no-install-recommends \
|
||||||
|
ca-certificates wget unzip && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN mkdir -p /opt/Trackmania && \
|
||||||
|
wget -q -O /tmp/trackmania-server.zip "https://nadeo-download.cdn.ubi.com/trackmania/TrackmaniaServer_${VERSION}.zip" && \
|
||||||
|
unzip /tmp/trackmania-server.zip -d /opt/Trackmania/ && \
|
||||||
|
rm -f /tmp/trackmania-server.zip && \
|
||||||
|
rm -rf /opt/Trackmania/TrackmaniaServer.exe /opt/Trackmania/RemoteControlExamples && \
|
||||||
|
mv /opt/Trackmania/UserData /opt/Trackmania/UserDataSaved && \
|
||||||
|
mkdir -p /opt/Trackmania/UserData
|
||||||
|
|
||||||
#Download base image debian 12
|
#Download base image debian 12
|
||||||
FROM debian:bookworm
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
ARG VERSION="Latest"
|
ARG VERSION="Latest"
|
||||||
|
|
||||||
# Add labels
|
# Add labels
|
||||||
LABEL "server.game"="Trackmania"
|
LABEL server.game="Trackmania" server.version="${VERSION}"
|
||||||
LABEL "server.version"=${VERSION}
|
|
||||||
|
|
||||||
# Update repository
|
# Copy from builder image
|
||||||
RUN apt-get update
|
COPY --from=builder /opt/Trackmania /opt/Trackmania
|
||||||
|
|
||||||
# install dependencies
|
# Install dependencies and clean up
|
||||||
RUN apt-get install -y zip git vim wget xmlstarlet ncat xxd
|
RUN apt update && \
|
||||||
|
apt install -y --no-install-recommends \
|
||||||
|
xmlstarlet ncat && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Prepare environment
|
VOLUME [ "/opt/Trackmania/UserData" ]
|
||||||
RUN mkdir -p /opt/Trackmania
|
|
||||||
|
|
||||||
RUN wget -q -O /tmp/trackmania-server.zip "https://nadeo-download.cdn.ubi.com/trackmania/TrackmaniaServer_${VERSION}.zip"
|
|
||||||
RUN unzip /tmp/trackmania-server.zip -d /opt/Trackmania/
|
|
||||||
RUN rm -f /tmp/trackmania-server.zip
|
|
||||||
|
|
||||||
RUN cp -r /opt/Trackmania/UserData /opt/Trackmania/UserDataSaved
|
|
||||||
|
|
||||||
VOLUME /opt/Trackmania/UserData
|
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
@ -13,14 +13,14 @@ if [ ! "$DEDICATED_CFG" ]; then
|
|||||||
echo "You must have a the NAME environment variable set."
|
echo "You must have a the NAME environment variable set."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! "$MASTER_LOGIN" -a ! "$MASTER_PASSWORD" ]; then
|
if [ -z "$MASTER_LOGIN" ] && [ -z "$MASTER_PASSWORD" ]; then
|
||||||
echo "No config, master login or name given. Starting in LAN mode"
|
echo "No config, master login or name given. Starting in LAN mode"
|
||||||
fi
|
fi
|
||||||
if [ ! -f UserData/Config/${DEDICATED_CFG_ARG} ]; then
|
if [ ! -f "UserData/Config/${DEDICATED_CFG_ARG}" ]; then
|
||||||
cp UserData/Config/dedicated_cfg.default.txt UserData/Config/${DEDICATED_CFG_ARG}
|
cp "UserData/Config/dedicated_cfg.default.txt" "UserData/Config/${DEDICATED_CFG_ARG}"
|
||||||
fi
|
fi
|
||||||
# password escape workaround
|
# password escape workaround
|
||||||
if [ ${MASTER_PASSWORD+x} ]; then MASTER_PASSWORD=$(echo ${MASTER_PASSWORD} | sed -e 's/\$/\\\$/g' -e 's/`/\\`/g'); fi
|
if [ ${MASTER_PASSWORD+x} ]; then MASTER_PASSWORD=$(echo "${MASTER_PASSWORD}" | sed -e 's/\$/\\\$/g' -e 's/`/\\`/g'); fi
|
||||||
|
|
||||||
configs=()
|
configs=()
|
||||||
if [ ${SUPERADMIN_PASSWORD+x} ]; then configs+=("'/dedicated/authorization_levels/level[1]/password' -v \"${SUPERADMIN_PASSWORD}\""); fi
|
if [ ${SUPERADMIN_PASSWORD+x} ]; then configs+=("'/dedicated/authorization_levels/level[1]/password' -v \"${SUPERADMIN_PASSWORD}\""); fi
|
||||||
@ -80,7 +80,7 @@ if [ ! "$DEDICATED_CFG" ]; then
|
|||||||
|
|
||||||
# write config parameters into config file
|
# write config parameters into config file
|
||||||
for (( i = 0; i < ${#configs[@]} ; i++ )); do
|
for (( i = 0; i < ${#configs[@]} ; i++ )); do
|
||||||
eval xmlstarlet ed -L -P -u ${configs[$i]} UserData/Config/${DEDICATED_CFG_ARG}
|
eval xmlstarlet ed -L -P -u "${configs[$i]}" "UserData/Config/${DEDICATED_CFG_ARG}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
DEDICATED_CFG_ARG=${DEDICATED_CFG}
|
DEDICATED_CFG_ARG=${DEDICATED_CFG}
|
||||||
@ -94,12 +94,12 @@ else
|
|||||||
MATCHSETTING="tracklist.txt"
|
MATCHSETTING="tracklist.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f UserData/Maps/MatchSettings/${MATCHSETTING} ]; then
|
if [ ! -f "UserData/Maps/MatchSettings/${MATCHSETTING}" ]; then
|
||||||
cp UserData/Maps/MatchSettings/example.txt UserData/Maps/MatchSettings/${MATCHSETTING}
|
cp "UserData/Maps/MatchSettings/example.txt" "UserData/Maps/MatchSettings/${MATCHSETTING}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SCRIPT_NAME" ]; then
|
if [ "$SCRIPT_NAME" ]; then
|
||||||
sed -i "s#<script_name>.*<\/script_name>#<script_name>${SCRIPT_NAME}</script_name>#g" UserData/Maps/MatchSettings/${MATCHSETTING}
|
sed -i "s#<script_name>.*<\/script_name>#<script_name>${SCRIPT_NAME}</script_name>#g" "UserData/Maps/MatchSettings/${MATCHSETTING}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec ./TrackmaniaServer /nodaemon /nologs /dedicated_cfg=${DEDICATED_CFG_ARG} /game_settings=MatchSettings/${MATCHSETTING} $@
|
exec ./TrackmaniaServer /nodaemon /nologs /dedicated_cfg="${DEDICATED_CFG_ARG}" /game_settings="MatchSettings/${MATCHSETTING}" $@
|
||||||
|
Reference in New Issue
Block a user