-
Notifications
You must be signed in to change notification settings - Fork 276
/
Dockerfile
179 lines (166 loc) · 7.01 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
FROM debian:bullseye-slim as build-env
ENV DEBIAN_FRONTEND=noninteractive
ARG TESTS
ARG SOURCE_COMMIT
ARG BUSYBOX_VERSION=1.34.1
ARG SUPERVISOR_VERSION=4.2.4
RUN apt-get update
RUN apt-get -y install apt-utils
RUN apt-get -y install build-essential curl git python3 python3-pip golang shellcheck
WORKDIR /build/busybox
RUN curl -L -o /tmp/busybox.tar.bz2 https://busybox.net/downloads/busybox-${BUSYBOX_VERSION}.tar.bz2 \
&& tar xjvf /tmp/busybox.tar.bz2 --strip-components=1 -C /build/busybox \
&& make defconfig \
&& sed -i -e "s/^CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=.*/CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=2048/" .config \
&& make \
&& cp busybox /usr/local/bin/
WORKDIR /build/env2cfg
COPY ./env2cfg/ /build/env2cfg/
RUN if [ "${TESTS:-true}" = true ]; then \
pip3 install tox \
&& tox \
; \
fi
RUN python3 setup.py bdist --format=gztar
WORKDIR /build/valheim-logfilter
COPY ./valheim-logfilter/ /build/valheim-logfilter/
RUN go build -ldflags="-s -w" \
&& mv valheim-logfilter /usr/local/bin/
WORKDIR /build
RUN git clone https://github.com/Yepoleb/python-a2s.git \
&& cd python-a2s \
&& python3 setup.py bdist --format=gztar
WORKDIR /build/supervisor
RUN curl -L -o /tmp/supervisor.tar.gz https://github.com/Supervisor/supervisor/archive/${SUPERVISOR_VERSION}.tar.gz \
&& tar xzvf /tmp/supervisor.tar.gz --strip-components=1 -C /build/supervisor \
&& python3 setup.py bdist --format=gztar
COPY bootstrap /usr/local/sbin/
COPY valheim-status /usr/local/bin/
COPY valheim-is-idle /usr/local/bin/
COPY valheim-bootstrap /usr/local/bin/
COPY valheim-backup /usr/local/bin/
COPY valheim-updater /usr/local/bin/
COPY valheim-plus-updater /usr/local/bin/
COPY bepinex-updater /usr/local/bin/
COPY valheim-server /usr/local/bin/
COPY defaults /usr/local/etc/valheim/
COPY common /usr/local/etc/valheim/
COPY contrib/* /usr/local/share/valheim/contrib/
RUN chmod 755 /usr/local/sbin/bootstrap /usr/local/bin/valheim-*
RUN if [ "${TESTS:-true}" = true ]; then \
shellcheck -a -x -s bash -e SC2034 \
/usr/local/sbin/bootstrap \
/usr/local/bin/valheim-backup \
/usr/local/bin/valheim-is-idle \
/usr/local/bin/valheim-bootstrap \
/usr/local/bin/valheim-server \
/usr/local/bin/valheim-updater \
/usr/local/bin/valheim-plus-updater \
/usr/local/bin/bepinex-updater \
/usr/local/share/valheim/contrib/*.sh \
; \
fi
WORKDIR /
RUN rm -rf /usr/local/lib/
RUN tar xzvf /build/supervisor/dist/supervisor-*.linux-x86_64.tar.gz
RUN tar xzvf /build/env2cfg/dist/env2cfg-*.linux-x86_64.tar.gz
RUN tar xzvf /build/python-a2s/dist/python-a2s-*.linux-x86_64.tar.gz
COPY supervisord.conf /usr/local/etc/supervisord.conf
RUN mkdir -p /usr/local/etc/supervisor/conf.d/ \
&& chmod 640 /usr/local/etc/supervisord.conf
RUN echo "${SOURCE_COMMIT:-unknown}" > /usr/local/etc/git-commit.HEAD
FROM --platform=linux/386 debian:buster-slim as i386-libs
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
libc6-dev \
libstdc++6 \
libsdl2-2.0-0 \
libcurl4 \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
FROM debian:bullseye-slim
ENV DEBIAN_FRONTEND=noninteractive
COPY --from=build-env /usr/local/ /usr/local/
COPY --from=i386-libs /lib/ld-linux.so.2 /lib/ld-linux.so.2
COPY --from=i386-libs /lib/i386-linux-gnu /lib/i386-linux-gnu
COPY --from=i386-libs /usr/lib/i386-linux-gnu /usr/lib/i386-linux-gnu
COPY fake-supervisord /usr/bin/supervisord
RUN groupadd -g "${PGID:-0}" -o valheim \
&& useradd -g "${PGID:-0}" -u "${PUID:-0}" -o --create-home valheim \
&& apt-get update \
&& apt-get -y --no-install-recommends install apt-utils \
&& apt-get -y dist-upgrade \
&& apt-get -y --no-install-recommends install \
libc6-dev \
libsdl2-2.0-0 \
cron \
curl \
iproute2 \
libcurl4 \
ca-certificates \
procps \
locales \
unzip \
zip \
rsync \
openssh-client \
jq \
python3-minimal \
python3-pkg-resources \
python3-setuptools \
libpulse-dev \
libatomic1 \
libc6 \
&& echo 'LANG="en_US.UTF-8"' > /etc/default/locale \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& rm -f /bin/sh \
&& ln -s /bin/bash /bin/sh \
&& locale-gen \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
&& usermod -a -G crontab valheim \
&& apt-get clean \
&& mkdir -p /var/spool/cron/crontabs /var/log/supervisor /opt/valheim /opt/steamcmd /home/valheim/.config/unity3d/IronGate /config /var/run/valheim \
&& ln -s /config /home/valheim/.config/unity3d/IronGate/Valheim \
&& ln -s /usr/local/bin/busybox /usr/local/sbin/syslogd \
&& ln -s /usr/local/bin/busybox /usr/local/sbin/mkpasswd \
&& ln -s /usr/local/bin/busybox /usr/local/bin/vi \
&& ln -s /usr/local/bin/busybox /usr/local/bin/patch \
&& ln -s /usr/local/bin/busybox /usr/local/bin/unix2dos \
&& ln -s /usr/local/bin/busybox /usr/local/bin/dos2unix \
&& ln -s /usr/local/bin/busybox /usr/local/bin/makemime \
&& ln -s /usr/local/bin/busybox /usr/local/bin/xxd \
&& ln -s /usr/local/bin/busybox /usr/local/bin/wget \
&& ln -s /usr/local/bin/busybox /usr/local/bin/less \
&& ln -s /usr/local/bin/busybox /usr/local/bin/lsof \
&& ln -s /usr/local/bin/busybox /usr/local/bin/httpd \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ssl_client \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ip \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ipcalc \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ping \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ping6 \
&& ln -s /usr/local/bin/busybox /usr/local/bin/iostat \
&& ln -s /usr/local/bin/busybox /usr/local/bin/setuidgid \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ftpget \
&& ln -s /usr/local/bin/busybox /usr/local/bin/ftpput \
&& ln -s /usr/local/bin/busybox /usr/local/bin/bzip2 \
&& ln -s /usr/local/bin/busybox /usr/local/bin/xz \
&& ln -s /usr/local/bin/busybox /usr/local/bin/pstree \
&& ln -s /usr/local/bin/busybox /usr/local/bin/killall \
&& ln -s /usr/local/bin/busybox /usr/local/bin/bc \
&& curl -L -o /tmp/steamcmd_linux.tar.gz https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz \
&& tar xzvf /tmp/steamcmd_linux.tar.gz -C /opt/steamcmd/ \
&& chown valheim:valheim /var/run/valheim \
&& chown -R root:root /opt/steamcmd \
&& chmod 755 /opt/steamcmd/steamcmd.sh \
/opt/steamcmd/linux32/steamcmd \
/opt/steamcmd/linux32/steamerrorreporter \
/usr/bin/supervisord \
&& cd "/opt/steamcmd" \
&& su - valheim -c "/opt/steamcmd/steamcmd.sh +login anonymous +quit" \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& date --utc --iso-8601=seconds > /usr/local/etc/build.date
EXPOSE 2456-2457/udp
EXPOSE 9001/tcp
EXPOSE 80/tcp
WORKDIR /
CMD ["/usr/local/sbin/bootstrap"]