Skip to content

Commit

Permalink
add cusom image
Browse files Browse the repository at this point in the history
  • Loading branch information
gOOvER committed Jul 14, 2024
1 parent 5c5f48f commit c8253b0
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
matrix:
oses:
- node16132
- rustserverredirect

steps:
- uses: actions/checkout@v4
Expand Down
146 changes: 146 additions & 0 deletions custom/rustserverredirect/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
FROM --platform=$BUILDPLATFORM debian:bookworm-slim

LABEL author="Torsten Widmann" maintainer="[email protected]"
LABEL org.opencontainers.image.source="https://github.com/gOOvER/own-pterodactyl-images"
LABEL org.opencontainers.image.licenses=MIT

# Update the repository and install needed packages
ARG DEBIAN_FRONTEND=noninteractive
COPY sources.list /etc/apt/sources.list
RUN dpkg --add-architecture i386
RUN apt update \
&& apt -y upgrade

RUN apt install -y --install-recommends \
ca-certificates \
curl \
dbus \
dirmngr \
g++ \
gcc \
gcc-12-base \
gdb \
gettext \
git \
gnupg \
iproute2 \
jq \
locales \
mesa-utils \
net-tools \
netcat-openbsd \
numactl \
psmisc \
python3 \
python3-dev \
python3-pip \
sed \
software-properties-common \
speex:i386 \
tar \
telnet \
tini \
tzdata \
wget \
lib32gcc-s1 \
lib32stdc++6 \
lib32tinfo6 \
libtinfo6:i386 \
lib32z1 \
libasound2 \
libatk1.0-0 \
libatomic1 \
libc++-dev \
libc++1 \
libc6 \
libc6:i386 \
libcurl3-gnutls \
libcurl3-gnutls:i386 \
libcurl4 \
libcurl4-gnutls-dev \
libcurl4-gnutls-dev:i386 \
libcurl4:i386 \
libfontconfig \
libgcc-s1 \
libgcc1 \
libgconf-2-4 \
libgdiplus \
libgtk2.0-0:i386 \
libjemalloc2 \
libjemalloc2:i386 \
libnss-wrapper \
libnss3 \
libpangocairo-1.0-0 \
libpulse-dev \
libpulse0 \
libsdl1.2-compat \
libsdl1.2-compat:i386 \
libsdl1.2debian \
libsdl1.2debian:i386 \
libsdl2-2.0-0 \
libsdl2-2.0-0:i386 \
libssl3 \
libssl3:i386 \
libstdc++6 \
libstdc++6:i386 \
libtcmalloc-minimal4 \
libtcmalloc-minimal4:i386 \
libtinfo6:i386 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxi6 \
libxrandr2 \
libxss1 \
libxtst6

## install dotnet to support STEAM dotnet games
RUN apt update -y \
&& apt upgrade -y \
&& wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt update -y \
&& apt install -y \
aspnetcore-runtime-8.0 \
dotnet-sdk-8.0

## install Mono
RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list
RUN apt update
RUN apt install -y mono-complete

## install rcon
RUN cd /tmp/ \
&& curl -sSL https://github.com/gorcon/rcon-cli/releases/download/v0.10.3/rcon-0.10.3-amd64_linux.tar.gz > rcon.tar.gz \
&& tar xvf rcon.tar.gz \
&& mv rcon-0.10.3-amd64_linux/rcon /usr/local/bin/

# 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

## Prepare NSS Wrapper for the entrypoint as a workaround for games 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} \
&& chmod g+rw ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP}
ADD passwd.template /passwd.template

## 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

# Sets the default stop signal as wings can (currently) only send a kill or generic stop
STOPSIGNAL SIGINT

COPY --chown=container:container ../entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
CMD ["/entrypoint.sh"]
146 changes: 146 additions & 0 deletions custom/rustserverredirect/Dockerfile copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
FROM --platform=$BUILDPLATFORM debian:bookworm-slim

LABEL author="Torsten Widmann" maintainer="[email protected]"
LABEL org.opencontainers.image.source="https://github.com/gOOvER/own-pterodactyl-images"
LABEL org.opencontainers.image.licenses=MIT

# Update the repository and install needed packages
ARG DEBIAN_FRONTEND=noninteractive
COPY sources.list /etc/apt/sources.list
RUN dpkg --add-architecture i386
RUN apt update \
&& apt -y upgrade

RUN apt install -y --install-recommends \
ca-certificates \
curl \
dbus \
dirmngr \
g++ \
gcc \
gcc-12-base \
gdb \
gettext \
git \
gnupg \
iproute2 \
jq \
locales \
mesa-utils \
net-tools \
netcat-openbsd \
numactl \
psmisc \
python3 \
python3-dev \
python3-pip \
sed \
software-properties-common \
speex:i386 \
tar \
telnet \
tini \
tzdata \
wget \
lib32gcc-s1 \
lib32stdc++6 \
lib32tinfo6 \
libtinfo6:i386 \
lib32z1 \
libasound2 \
libatk1.0-0 \
libatomic1 \
libc++-dev \
libc++1 \
libc6 \
libc6:i386 \
libcurl3-gnutls \
libcurl3-gnutls:i386 \
libcurl4 \
libcurl4-gnutls-dev \
libcurl4-gnutls-dev:i386 \
libcurl4:i386 \
libfontconfig \
libgcc-s1 \
libgcc1 \
libgconf-2-4 \
libgdiplus \
libgtk2.0-0:i386 \
libjemalloc2 \
libjemalloc2:i386 \
libnss-wrapper \
libnss3 \
libpangocairo-1.0-0 \
libpulse-dev \
libpulse0 \
libsdl1.2-compat \
libsdl1.2-compat:i386 \
libsdl1.2debian \
libsdl1.2debian:i386 \
libsdl2-2.0-0 \
libsdl2-2.0-0:i386 \
libssl3 \
libssl3:i386 \
libstdc++6 \
libstdc++6:i386 \
libtcmalloc-minimal4 \
libtcmalloc-minimal4:i386 \
libtinfo6:i386 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxi6 \
libxrandr2 \
libxss1 \
libxtst6

## install dotnet to support STEAM dotnet games
RUN apt update -y \
&& apt upgrade -y \
&& wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt update -y \
&& apt install -y \
aspnetcore-runtime-8.0 \
dotnet-sdk-8.0

## install Mono
RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list
RUN apt update
RUN apt install -y mono-complete

## install rcon
RUN cd /tmp/ \
&& curl -sSL https://github.com/gorcon/rcon-cli/releases/download/v0.10.3/rcon-0.10.3-amd64_linux.tar.gz > rcon.tar.gz \
&& tar xvf rcon.tar.gz \
&& mv rcon-0.10.3-amd64_linux/rcon /usr/local/bin/

# 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

## Prepare NSS Wrapper for the entrypoint as a workaround for games 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} \
&& chmod g+rw ${NSS_WRAPPER_PASSWD} ${NSS_WRAPPER_GROUP}
ADD passwd.template /passwd.template

## 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

# Sets the default stop signal as wings can (currently) only send a kill or generic stop
STOPSIGNAL SIGINT

COPY --chown=container:container ../entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
CMD ["/entrypoint.sh"]
66 changes: 66 additions & 0 deletions custom/rustserverredirect/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

clear
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# 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

# Information output
echo -e "${BLUE}---------------------------------------------------------------------${NC}"
echo -e "${RED}RustServerRedirect Image by gOOvER${NC}"
echo -e "${BLUE}---------------------------------------------------------------------${NC}"
echo -e "${YELLOW}Running on Debian: ${RED} $(cat /etc/debian_version)${NC}"
echo -e "${YELLOW}Current timezone: ${RED} $(cat /etc/timezone)${NC}"
echo -e "${YELLOW}DotNet Version: ${RED} $(dotnet --version) ${NC}"
echo -e "${BLUE}---------------------------------------------------------------------${NC}"

# Switch to the container's working directory
cd /home/container || exit 1

# writing dotnet infos to file
#dotnetinfo=$(dotnet --info)
#echo $dotnetinfo >| dotnet_info.txt

echo -e "${BLUE}---------------------------------------------------------------------${NC}"
echo -e "${GREEN}Starting Server.... Please wait...${NC}"
echo -e "${BLUE}---------------------------------------------------------------------${NC}"

FILE=$HOME/RustServerRedirect

if [ -f "$FILE" ]; then
echo -e "${BLUE}-------------------------------------------------${NC}"
echo -e "${GREEN}RustServerRedirect found.${NC}"
echo -e "${BLUE}-------------------------------------------------${NC}"
chmod +x $FILE
else
echo -e "${BLUE}-------------------------------------------------${NC}"
echo -e "${RED}RustServerRedirect not found. exiting...${NC}"
echo -e "${BLUE}-------------------------------------------------${NC}"
exit 1
fi

# Setup NSS Wrapper for use ($NSS_WRAPPER_PASSWD and $NSS_WRAPPER_GROUP have been set by the Dockerfile)
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
envsubst < /passwd.template > ${NSS_WRAPPER_PASSWD}
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libnss_wrapper.so

# Replace Startup Variables
MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
echo -e ":/home/container$ ${MODIFIED_STARTUP}"

# Run the Server
eval ${MODIFIED_STARTUP}
26 changes: 26 additions & 0 deletions custom/rustserverredirect/passwd.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
syslog:x:104:108::/home/syslog:/bin/false
messagebus:x:106:109::/var/run/dbus:/bin/false
bind:x:108:112::/var/cache/bind:/bin/false
${USER_NAME}:x:${USER_ID}:${GROUP_ID}:${USER_NAME}:${HOME}:/bin/bash
Loading

0 comments on commit c8253b0

Please sign in to comment.