diff --git a/games/rust/Dockerfile b/games/rust/Dockerfile index 540f444..ace5eea 100644 --- a/games/rust/Dockerfile +++ b/games/rust/Dockerfile @@ -1,21 +1,41 @@ -FROM --platform=$TARGETOS/$TARGETARCH node:18-slim - -ENV DEBIAN_FRONTEND=noninteractive - -RUN dpkg --add-architecture i386 \ - && apt update \ - && apt upgrade -y \ - && apt install -y lib32gcc-s1 lib32stdc++6 unzip curl iproute2 tzdata libgdiplus libsdl2-2.0-0:i386 \ - && mkdir /wrapper \ - && npm install --prefix /wrapper ws \ - && useradd -d /home/container -m container - -USER container -ENV USER=container HOME=/home/container - -WORKDIR /home/container - -COPY ./entrypoint.sh /entrypoint.sh -COPY ./wrapper.js /wrapper/wrapper.js - -CMD [ "/bin/bash", "/entrypoint.sh" ] \ No newline at end of file +FROM node:22-slim + +ARG DEBIAN_FRONTEND=noninteractive + +RUN dpkg --add-architecture i386 \ + && apt update \ + && apt upgrade -y + +RUN apt install -y \ + lib32gcc-s1 \ + lib32stdc++6 \ + locales \ + unzip \ + curl \ + iproute2 \ + tzdata \ + libgdiplus \ + libsdl2-2.0-0:i386 + +RUN mkdir /wrapper \ + && npm install --prefix /wrapper ws + +# Set the locale +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US:en +ENV LC_ALL=en_US.UTF-8 + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container + +WORKDIR /home/container + +COPY ./entrypoint.sh /entrypoint.sh +COPY --chown=container:container ./wrapper.js /wrapper/wrapper.js +RUN chmod +x /wrapper/wrapper.js + +CMD [ "/bin/bash", "/entrypoint.sh" ] diff --git a/games/rust/entrypoint.sh b/games/rust/entrypoint.sh index 6aefa1b..b9ca5f4 100644 --- a/games/rust/entrypoint.sh +++ b/games/rust/entrypoint.sh @@ -1,8 +1,18 @@ #!/bin/bash -cd /home/container -# Make internal Docker IP address available to processes. -export INTERNAL_IP=`ip route get 1 | awk '{print $(NF-2);exit}'` +# Wait for the container to fully initialize +sleep 1 + +# Default the TZ environment variable to UTC. +TZ=${TZ:-UTC} +export TZ + +# Set environment variable that holds the Internal Docker IP +INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') +export INTERNAL_IP + +# Switch to the container's working directory +cd /home/container || exit 1 ## if auto_update is not set or to 1 update if [ -z ${AUTO_UPDATE} ] || [ "${AUTO_UPDATE}" == "1" ]; then @@ -13,7 +23,7 @@ else fi # Replace Startup Variables -MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` +MODIFIED_STARTUP=$(eval echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g') echo ":/home/container$ ${MODIFIED_STARTUP}" if [[ "${FRAMEWORK}" == "carbon" ]]; then