Arma 3 Image Cleanup & Refurbishment

Files:
- Remove dependency of having `libnss_wrapper.so` libraries directly in the image. Instead, use the libraries provided with their respective packages. This fixes the current 32-bit version being broken and ensures the libraries stay up to date with their respective packages.
- Slight change to passwd.template to accommodate variable name change.

Dockerfile:
- Change the base image to Debian, which from testing appears to run cleaner and faster for Arma. It also should yield a smaller image.
- Fix depreciated `ENV` call format.
- Removed un-needed packages.
- Added iproute2 package.
- Consolidated the NSS Wrapper setup to a commented group of lines to make understanding it's purpose and setup more clear.
- Added shell flag to `useradd` command.

Entrypoint:
- General cleanup.
- Changed `LD_PRELOAD`s to point to package-provided library file locations.
This commit is contained in:
Red-Thirten
2022-05-22 17:35:03 -07:00
parent cc7a9d0da5
commit e750a642c9
5 changed files with 49 additions and 24 deletions

View File

@@ -1,29 +1,51 @@
FROM ubuntu:20.04 FROM --platform=$BUILDPLATFORM debian:stable-slim
LABEL author="David Wolfe (Red-Thirten)" maintainer="rehlmgaming@gmail.com" LABEL author="David Wolfe (Red-Thirten)" maintainer="rehlmgaming@gmail.com"
ENV DEBIAN_FRONTEND noninteractive
ENV USER_NAME container
ENV NSS_WRAPPER_PASSWD /tmp/passwd
ENV NSS_WRAPPER_GROUP /tmp/group
# Install Dependencies LABEL org.opencontainers.image.source="https://github.com/parkervcp/yolks"
LABEL org.opencontainers.image.licenses=MIT
## Update base packages and install dependencies
ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg --add-architecture i386 \ RUN dpkg --add-architecture i386 \
&& apt-get update \ && apt-get update \
&& apt-get upgrade -y \ && apt-get upgrade -y \
&& apt-get install -y libgcc-10-dev libstdc++-10-dev libtinfo5 lib64z1 libcurl3-gnutls \ && apt-get install -y \
&& apt-get install -y libnss-wrapper gettext-base tar curl gcc g++ libc6 libtbb2 lib32z1 lib32gcc1 lib32stdc++6 libsdl2-2.0-0 libsdl2-2.0-0:i386 libtbb2:i386 lib32stdc++6 libtinfo5:i386 libncurses5:i386 libcurl3-gnutls:i386 tzdata \ curl \
&& useradd -m -d /home/container -s /bin/bash container \ tzdata \
&& touch ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP} \ locales \
iproute2 \
gettext-base \
ca-certificates \
libssl-dev \
lib32gcc-s1 \
libsdl2-2.0-0 \
libsdl2-2.0-0:i386 \
libstdc++6 \
libstdc++6:i386 \
lib32stdc++6 \
libnss-wrapper \
libnss-wrapper:i386 \
libtbb2 \
libtbb2:i386
## Configure locale
RUN update-locale lang=en_US.UTF-8 \
&& dpkg-reconfigure --frontend noninteractive locales
## Prepare NSS Wrapper for the entrypoint as a workaround for Arma 3 requiring a valid UID
ENV NSS_WRAPPER_PASSWD=/tmp/passwd NSS_WRAPPER_GROUP=/tmp/group
RUN touch ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP} \
&& chgrp 0 ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP} \ && chgrp 0 ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP} \
&& chmod g+rw ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP} && chmod g+rw ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP}
ADD passwd.template /passwd.template ADD passwd.template /passwd.template
## Setup user and working directory
RUN useradd -m -d /home/container -s /bin/bash container
USER container USER container
ENV HOME /home/container ENV USER=container HOME=/home/container
WORKDIR /home/container WORKDIR /home/container
COPY ./libnss_wrapper.so /libnss_wrapper.so ## Copy over and execute entrypoint.sh
COPY ./libnss_wrapper_x64.so /libnss_wrapper_x64.so
COPY ./entrypoint.sh /entrypoint.sh COPY ./entrypoint.sh /entrypoint.sh
CMD [ "/bin/bash", "/entrypoint.sh" ] CMD [ "/bin/bash", "/entrypoint.sh" ]

View File

@@ -2,8 +2,8 @@
## File: Pterodactyl Arma 3 Image - entrypoint.sh ## File: Pterodactyl Arma 3 Image - entrypoint.sh
## Author: David Wolfe (Red-Thirten) ## Author: David Wolfe (Red-Thirten)
## Contributors: Aussie Server Hosts (https://aussieserverhosts.com/) ## Contributors: Aussie Server Hosts (https://aussieserverhosts.com/), Stephen White (SilK)
## Date: 2021/07/13 ## Date: 2022/05/22
## License: MIT License ## License: MIT License
## === CONSTANTS === ## === CONSTANTS ===
@@ -167,12 +167,15 @@ function RemoveDuplicates { #[Input: str - Output: printf of new str]
# === ENTRYPOINT START === # === ENTRYPOINT START ===
# Wait for the container to fully initialize
sleep 1
# Set environment variable that holds the Internal Docker IP # Set environment variable that holds the Internal Docker IP
INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
export INTERNAL_IP export INTERNAL_IP
cd /home/container # Switch to the container's working directory
sleep 1 cd /home/container || exit 1
# Check for old eggs # Check for old eggs
if [[ -z ${VALIDATE_SERVER} ]]; then # VALIDATE_SERVER was not in the previous version if [[ -z ${VALIDATE_SERVER} ]]; then # VALIDATE_SERVER was not in the previous version
@@ -350,15 +353,15 @@ if [[ ! -f ./basic.cfg ]]; then
curl -sSL ${BASIC_URL} -o ./basic.cfg curl -sSL ${BASIC_URL} -o ./basic.cfg
fi fi
# $NSS_WRAPPER_PASSWD and $NSS_WRAPPER_GROUP have been set by the Dockerfile # Setup NSS Wrapper for use ($NSS_WRAPPER_PASSWD and $NSS_WRAPPER_GROUP have been set by the Dockerfile)
export USER_ID=$(id -u) export USER_ID=$(id -u)
export GROUP_ID=$(id -g) export GROUP_ID=$(id -g)
envsubst < /passwd.template > ${NSS_WRAPPER_PASSWD} envsubst < /passwd.template > ${NSS_WRAPPER_PASSWD}
if [[ ${SERVER_BINARY} == *"x64"* ]]; then # Check which libnss_wrapper architecture to run, based off the server binary name if [[ ${SERVER_BINARY} == *"x64"* ]]; then # Check which libnss-wrapper architecture to run, based off the server binary name
export LD_PRELOAD=/libnss_wrapper_x64.so export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libnss_wrapper.so
else else
export LD_PRELOAD=/libnss_wrapper.so export LD_PRELOAD=/usr/lib/i386-linux-gnu/libnss_wrapper.so
fi fi
# Replace Startup Variables # Replace Startup Variables

Binary file not shown.

Binary file not shown.

View File

@@ -23,4 +23,4 @@ systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
syslog:x:104:108::/home/syslog:/bin/false syslog:x:104:108::/home/syslog:/bin/false
messagebus:x:106:109::/var/run/dbus:/bin/false messagebus:x:106:109::/var/run/dbus:/bin/false
bind:x:108:112::/var/cache/bind:/bin/false bind:x:108:112::/var/cache/bind:/bin/false
${USER_NAME}:x:${USER_ID}:${GROUP_ID}:${USER_NAME}:${HOME}:/bin/bash ${USER}:x:${USER_ID}:${GROUP_ID}:${USER}:${HOME}:/bin/bash