Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/fix config and docker #15

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
tmp/
docs/


.idea/
.github
README.md
Makefile
docker-compose*
enshrouded.iml
/tmp
/docs
223 changes: 114 additions & 109 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,109 +1,114 @@
# --------------- #
# -- Steam CMD -- #
# --------------- #
FROM steamcmd/steamcmd:ubuntu

ARG WINEARCH=win64
ARG WINE_MONO_VERSION=4.9.4

ENV TZ=America/Los_Angeles
ENV PYTHONUNBUFFERED=1
ENV DISPLAY=:0
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y -qq \
build-essential \
htop net-tools nano gcc g++ gdb \
netcat curl wget zip unzip \
cron sudo gosu dos2unix jq \
tzdata python3 python3-pip \
# lib32z1 lib32gcc-s1 lib32stdc++6 \
&& rm -rf /var/lib/apt/lists/* \
&& gosu nobody true \
&& dos2unix

RUN addgroup --system steam \
&& adduser --system \
--home /home/steam \
--shell /bin/bash \
steam \
&& usermod -aG steam steam \
&& chmod ugo+rw /tmp/dumps

# Install wget
RUN apt-get update
RUN apt-get install -y wget

# Add 32-bit architecture
RUN dpkg --add-architecture i386
RUN apt-get update

# Install Wine
RUN apt-get install -y software-properties-common gnupg2
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
RUN apt-get install -y --install-recommends winehq-stable winbind
ENV WINEDEBUG=fixme-all


# Install Winetricks
RUN apt-get install -y cabextract
ADD --chmod=755 https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks /usr/local/bin/winetricks

# Install Xvfb
RUN apt-get install -y xvfb

# Container informaiton
ARG GITHUB_SHA="not-set"
ARG GITHUB_REF="not-set"
ARG GITHUB_REPOSITORY="not-set"

ENV PUID=1000
ENV PGID=1000

RUN usermod -u ${PUID} steam \
&& groupmod -g ${PGID} steam \
&& echo "steam ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER steam

WORKDIR /home/steam

ENV HOME=/home/steam
ENV USER=steam
ENV LD_LIBRARY_PATH="/home/steam/.steam/sdk32:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/home/steam/.steam/sdk64:${LD_LIBRARY_PATH}"
ENV PATH="/home/steam/.local/bin:${PATH}"


# Setup a Wine prefix
ENV WINEPREFIX=/home/steam/.wine
ENV WINEARCH=${WINEARCH}
RUN winecfg

# Install Mono
ADD https://dl.winehq.org/wine/wine-mono/${WINE_MONO_VERSION}/wine-mono-${WINE_MONO_VERSION}.msi /mono/wine-mono-${WINE_MONO_VERSION}.msi
RUN wineboot -u && sudo msiexec /i /mono/wine-mono-${WINE_MONO_VERSION}.msi \
&& sudo rm -rf /mono/wine-mono-${WINE_MONO_VERSION}.msi

COPY --chown=${PUID}:${PGID} ./Pipfile ./Pipfile.lock /home/steam/scripts/

RUN pip3 install pipenv \
&& cd /home/steam/scripts \
&& pipenv install --system --deploy --ignore-pipfile \
&& pip3 uninstall -y pipenv \
&& sudo chown -R steam:steam /home/steam

COPY --chown=${PUID}:${PGID} ./scripts /home/steam/scripts

EXPOSE 15636 15637

RUN echo "source /home/steam/scripts/utils.sh" >> /home/steam/.bashrc

#HEALTHCHECK --interval=1m --timeout=3s \
# CMD pidof valheim_server.x86_64 || exit 1

ENTRYPOINT ["/bin/bash","/home/steam/scripts/entrypoint.sh"]
# Stage 1: Base setup
FROM ubuntu:24.04 AS base
ARG DEBIAN_FRONTEND=noninteractive
ENV USER=root HOME=/root

# Set up steam
RUN /bin/bash -o pipefail -c ' \
echo steam steam/question select "I AGREE" | debconf-set-selections && \
echo steam steam/license note "" | debconf-set-selections && \
dpkg --add-architecture i386 && \
apt-get update -y && \
apt-get install -y --no-install-recommends ca-certificates locales steamcmd && \
rm -rf /var/lib/apt/lists/* && \
locale-gen en_US.UTF-8 && \
ln -s /usr/games/steamcmd /usr/bin/steamcmd && \
steamcmd +quit && \
mkdir -p $HOME/.steam && \
ln -s $HOME/.local/share/Steam/steamcmd/linux32 $HOME/.steam/sdk32 && \
ln -s $HOME/.local/share/Steam/steamcmd/linux64 $HOME/.steam/sdk64 && \
ln -s $HOME/.steam/sdk32/steamclient.so $HOME/.steam/sdk32/steamservice.so && \
ln -s $HOME/.steam/sdk64/steamclient.so $HOME/.steam/sdk64/steamservice.so'

ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en

# Stage 2: Wine setup
FROM base AS wine
ARG WINEARCH=win64
ARG WINE_MONO_VERSION=4.9.4
ENV TZ=America/Los_Angeles
ENV PYTHONUNBUFFERED=1 DISPLAY=:0 PUID=1000 PGID=1000

# Install dependencies
RUN /bin/bash -o pipefail -c ' \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
if [ "$(getent passwd $PUID | cut -d: -f1)" != "steam" ]; then userdel $(getent passwd $PUID | cut -d: -f1); fi && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y -qq build-essential htop net-tools nano gcc g++ gdb netcat-traditional curl wget zip unzip cron sudo gosu dos2unix jq tzdata && \
rm -rf /var/lib/apt/lists/* && \
gosu nobody true && \
dos2unix && \
addgroup --system steam && \
adduser --system --home /home/steam --shell /bin/bash steam && \
usermod -aG steam steam && \
chmod ugo+rw /tmp/dumps'

# Wine installation
ADD https://dl.winehq.org/wine-builds/winehq.key /tmp/winehq.key
RUN /bin/bash -o pipefail -c ' \
dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y software-properties-common gnupg2 && \
apt-key add /tmp/winehq.key && \
apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main" && \
apt-get install -y --install-recommends winehq-stable winbind cabextract && \
rm -rf /var/lib/apt/lists/*'

ENV WINEDEBUG=fixme-all

# Add winetricks
ADD --chmod=755 https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks /usr/local/bin/winetricks

# Stage 3: Python setup
FROM wine AS python
ARG WINEARCH=win64
ARG WINE_MONO_VERSION=4.9.4

# Install Python, pip, and pyinstaller in a virtual environment
RUN /bin/bash -o pipefail -c ' \
apt-get update && \
apt-get install -y python3 python3-venv && \
python3 -m venv /opt/venv && \
. /opt/venv/bin/activate && \
pip install --upgrade pip && \
pip install pyinstaller jinja2 && \
deactivate && \
rm -rf /var/lib/apt/lists/*'

WORKDIR /app

COPY . /app
RUN . /opt/venv/bin/activate && pyinstaller --onefile scripts/config.py

# Stage 4: Final stage
FROM python AS final
ARG GITHUB_SHA=not-set
ARG GITHUB_REF=not-set
ARG GITHUB_REPOSITORY=not-set
ENV ENSHROUDED_CONFIG_DIR=/usr/local/share/enshrouded-config
ENV CONFIG_TEMPLATE_PATH=/home/steam/scripts/templates/config.json.j2

COPY --from=python --chmod=steam /app/dist/ "${ENSHROUDED_CONFIG_DIR}"


# Copy entrypoint script with correct permissions
COPY --chmod=0755 --chown=steam:steam scripts/ /home/steam/scripts/
COPY --chmod=0755 --chown=steam:steam ./scripts/templates/config.json.j2 $CONFIG_TEMPLATE_PATH

RUN /bin/bash -o pipefail -c ' \
usermod -u ${PUID} steam && \
groupmod -g ${PGID} steam && \
echo "steam ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
mkdir -p "${ENSHROUDED_CONFIG_DIR}"'

# Switch to steam user
USER steam
WORKDIR /home/steam
ENV HOME=/home/steam USER=steam
ENV LD_LIBRARY_PATH=/home/steam/.steam/sdk32:/home/steam/.steam/sdk64:/home/steam/.steam/sdk32
ENV PATH=/home/steam/.local/bin:/usr/local/share/enshrouded-config:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Set entrypoint
ENTRYPOINT ["/home/steam/scripts/entrypoint.sh"]
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: dev

dev:
@docker compose up --build --abort-on-container-exit
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
environment:
SERVER_NAME: "My Enshrouded Server" # Optional, Name of the server
# PASSWORD: "" # Optional, Password for the server
# ADMIN_PASSWORD: "adminpassword" # Optional, Admin password for the server
# SAVE_DIRECTORY: ./savegame # Optional, Save directory for the game
# LOG_DIRECTORY: ./logs # Optional, Log directory for the server
# SERVER_IP: 0.0.0.0 # Optional, IP address for the server
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ services:
- linux/amd64
environment:
SERVER_NAME: "My Enshrouded Server" # Optional, Name of the server
# PASSWORD: "" # Optional, Password for the server
PASSWORD: "securepassword" # Optional, Password for the server
# ADMIN_PASSWORD: "adminpassword" # Optional, Admin password for the server
# SAVE_DIRECTORY: ./savegame # Optional, Save directory for the game
# LOG_DIRECTORY: ./logs # Optional, Log directory for the server
# SERVER_IP: 0.0.0.0 # Optional, IP address for the server
Expand Down
2 changes: 1 addition & 1 deletion enshrouded.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Pipenv (enshrouded-docker)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="3.11 @ Ubuntu" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Loading
Loading