improve image to reduce size
This commit is contained in:
47
Dockerfile
47
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
|
||||
FROM debian:bookworm
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# environment variables
|
||||
ARG VERSION="Latest"
|
||||
|
||||
# Add labels
|
||||
LABEL "server.game"="Trackmania"
|
||||
LABEL "server.version"=${VERSION}
|
||||
LABEL server.game="Trackmania" server.version="${VERSION}"
|
||||
|
||||
# Update repository
|
||||
RUN apt-get update
|
||||
# Copy from builder image
|
||||
COPY --from=builder /opt/Trackmania /opt/Trackmania
|
||||
|
||||
# install dependencies
|
||||
RUN apt-get install -y zip git vim wget xmlstarlet ncat xxd
|
||||
# Install dependencies and clean up
|
||||
RUN apt update && \
|
||||
apt install -y --no-install-recommends \
|
||||
xmlstarlet ncat && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Prepare environment
|
||||
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
|
||||
VOLUME [ "/opt/Trackmania/UserData" ]
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
@ -33,4 +44,4 @@ WORKDIR /opt/Trackmania/
|
||||
HEALTHCHECK --interval=5s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD nc -z -v 127.0.0.1 5000 || exit 1
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
@ -13,14 +13,14 @@ if [ ! "$DEDICATED_CFG" ]; then
|
||||
echo "You must have a the NAME environment variable set."
|
||||
exit 1
|
||||
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"
|
||||
fi
|
||||
if [ ! -f UserData/Config/${DEDICATED_CFG_ARG} ]; then
|
||||
cp UserData/Config/dedicated_cfg.default.txt UserData/Config/${DEDICATED_CFG_ARG}
|
||||
if [ ! -f "UserData/Config/${DEDICATED_CFG_ARG}" ]; then
|
||||
cp "UserData/Config/dedicated_cfg.default.txt" "UserData/Config/${DEDICATED_CFG_ARG}"
|
||||
fi
|
||||
# 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=()
|
||||
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
|
||||
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
|
||||
else
|
||||
DEDICATED_CFG_ARG=${DEDICATED_CFG}
|
||||
@ -94,12 +94,12 @@ else
|
||||
MATCHSETTING="tracklist.txt"
|
||||
fi
|
||||
|
||||
if [ ! -f UserData/Maps/MatchSettings/${MATCHSETTING} ]; then
|
||||
cp UserData/Maps/MatchSettings/example.txt UserData/Maps/MatchSettings/${MATCHSETTING}
|
||||
if [ ! -f "UserData/Maps/MatchSettings/${MATCHSETTING}" ]; then
|
||||
cp "UserData/Maps/MatchSettings/example.txt" "UserData/Maps/MatchSettings/${MATCHSETTING}"
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
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