-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
218 lines (177 loc) · 4.96 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
ARG MODE=mysql
FROM alpine:latest AS build-base
### Install build dependencies
RUN apk --quiet --no-cache add \
git \
build-base \
clang \
cmake \
make \
zlib-dev \
curl-dev \
lua-dev \
&& rm -rf /var/cache/apk/* \
;
### CMake & make
ARG REPO=https://github.com/pvpgn/pvpgn-server.git
ARG BRANCH=master
RUN git clone --depth 1 --single-branch --branch ${BRANCH} ${REPO} /src
RUN mkdir /src/build /usr/local/pvpgn
WORKDIR /src
ENV WITH_LUA=true
ENV WITH_MYSQL=false
ENV WITH_SQLITE3=false
ENV WITH_PGSQL=false
ENV WITH_ODBC=false
################################################################################
FROM build-base AS build-plain
RUN cmake -G "Unix Makefiles" -H./ -B./build \
-D WITH_LUA=${WITH_LUA} \
-D WITH_MYSQL=${WITH_MYSQL} \
-D WITH_SQLITE3=${WITH_SQLITE3} \
-D WITH_PGSQL=${WITH_PGSQL} \
-D WITH_ODBC=${WITH_ODBC} \
-D CMAKE_INSTALL_PREFIX=/ \
../ && cd build && make
################################################################################
FROM build-base AS build-mysql
RUN apk --quiet --no-cache add \
mariadb-dev \
&& rm -rf /var/cache/apk/* \
;
ENV WITH_MYSQL=true
RUN cmake -G "Unix Makefiles" -H./ -B./build \
-D WITH_LUA=${WITH_LUA} \
-D WITH_MYSQL=${WITH_MYSQL} \
-D WITH_SQLITE3=${WITH_SQLITE3} \
-D WITH_PGSQL=${WITH_PGSQL} \
-D WITH_ODBC=${WITH_ODBC} \
-D CMAKE_INSTALL_PREFIX=/ \
../ && cd build && make
################################################################################
FROM build-base AS build-pgsql
RUN apk --quiet --no-cache add \
libpq-dev \
&& rm -rf /var/cache/apk/* \
;
ENV WITH_PGSQL=true
RUN cmake -G "Unix Makefiles" -H./ -B./build \
-D WITH_LUA=${WITH_LUA} \
-D WITH_MYSQL=${WITH_MYSQL} \
-D WITH_SQLITE3=${WITH_SQLITE3} \
-D WITH_PGSQL=${WITH_PGSQL} \
-D WITH_ODBC=${WITH_ODBC} \
-D CMAKE_INSTALL_PREFIX=/ \
../ && cd build && make
################################################################################
FROM build-base AS build-sqlite3
RUN apk --quiet --no-cache add \
sqlite-dev \
&& rm -rf /var/cache/apk/* \
;
ENV WITH_SQLITE3=true
RUN cmake -G "Unix Makefiles" -H./ -B./build \
-D WITH_LUA=${WITH_LUA} \
-D WITH_MYSQL=${WITH_MYSQL} \
-D WITH_SQLITE3=${WITH_SQLITE3} \
-D WITH_PGSQL=${WITH_PGSQL} \
-D WITH_ODBC=${WITH_ODBC} \
-D CMAKE_INSTALL_PREFIX=/ \
../ && cd build && make
################################################################################
FROM build-base AS build-odbc
RUN apk --quiet --no-cache add \
unixodbc-dev \
&& rm -rf /var/cache/apk/* \
;
ENV WITH_ODBC=true
RUN cmake -G "Unix Makefiles" -H./ -B./build \
-D WITH_LUA=${WITH_LUA} \
-D WITH_MYSQL=${WITH_MYSQL} \
-D WITH_SQLITE3=${WITH_SQLITE3} \
-D WITH_PGSQL=${WITH_PGSQL} \
-D WITH_ODBC=${WITH_ODBC} \
-D CMAKE_INSTALL_PREFIX=/ \
../ && cd build && make
################################################################################
FROM build-${MODE} AS build
### Install
WORKDIR /src/build
RUN make install && chown -R 1001:1001 /var/pvpgn /etc/pvpgn
################################################################################
FROM alpine:latest AS runner-plain
### Install dependencies
RUN apk --quiet --no-cache add \
ca-certificates \
libstdc++ \
libgcc \
libcurl \
lua5.1-libs \
&& rm -rf /var/cache/apk/* \
;
################################################################################
FROM runner-plain AS runner-mysql
### Install dependencies
RUN apk --quiet --no-cache add \
mariadb-connector-c \
&& rm -rf /var/cache/apk/* \
;
################################################################################
FROM runner-plain AS runner-pgsql
### Install dependencies
RUN apk --quiet --no-cache add \
libpq \
&& rm -rf /var/cache/apk/* \
;
################################################################################
FROM runner-plain AS runner-sqlite3
### Install dependencies
RUN apk --quiet --no-cache add \
sqlite-libs \
&& rm -rf /var/cache/apk/* \
;
################################################################################
FROM runner-plain AS runner-odbc
## Install dependencies
RUN apk --quiet --no-cache add \
unixodbc \
&& rm -rf /var/cache/apk/* \
;
################################################################################
FROM runner-${MODE} AS runner
### Copy build files
COPY --from=build \
/sbin/bnetd \
/sbin/bntrackd \
/sbin/d2cs \
/sbin/d2dbs \
/sbin
COPY --from=build \
/bin/bn* \
/bin/sha1hash \
/bin/tgainfo \
/bin
COPY --from=build --chown=1001:1001 /etc/pvpgn /etc/pvpgn
COPY --from=build --chown=1001:1001 /var/pvpgn /var/pvpgn
### Prepare user
RUN addgroup --gid 1001 pvpgn \
&& adduser \
--home /var/pvpgn \
--gecos "" \
--shell /sbin/nologin \
--ingroup pvpgn \
--system \
--disabled-password \
--no-create-home \
--uid 1001 \
pvpgn
### persist data and configs
VOLUME /var/pvpgn
VOLUME /etc/pvpgn
# expose served network ports
EXPOSE 6112 4000
### Set user
USER 1001:1001
### RUN!
CMD ["bnetd", "-f"]
ENTRYPOINT ["bnetd"]