-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
114 lines (96 loc) Β· 4.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 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"]