-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathDockerfile
239 lines (163 loc) · 4.94 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
FROM node:12-alpine AS updated-node-alpine
RUN apk update && apk upgrade
#
# The preparation stage for use during the installation
# of app dependencies.
#
FROM updated-node-alpine AS build-ready
RUN apk add --no-cache git openssh
#
# Install depencencies from package.json
#
FROM build-ready AS app-js-depencencies
WORKDIR /build
COPY package*.json ./
RUN npm config set unsafe-perm true
RUN npm i --silent --quiet
#
# Transpiling (development).
#
FROM app-js-depencencies AS app-development-build
COPY tsconfig.json ./
COPY ./src ./src
COPY .env.example ./.env
RUN npm run build:dev
#
# Transpiling (production).
#
FROM app-js-depencencies AS app-production-build
COPY tsconfig.prod.json ./
COPY ./src ./src
COPY .env.production ./.env
RUN npm run build
#
# Removing non-production dependencies from node_modules.
#
FROM app-production-build AS production-js-dependencies
RUN npm prune --production
#
# Building game server image (development).
#
FROM updated-node-alpine as development-image
# Install uWebSockets deps.
RUN apk add --no-cache gcompat
RUN rm -rf /var/cache/apk/*
WORKDIR /app
RUN mkdir logs && chown -R node: logs
RUN mkdir cache && chown -R node: cache
RUN mkdir certs && chown -R node: certs
COPY --from=app-development-build /build/dist ./dist
COPY --from=app-js-depencencies /build/node_modules ./node_modules
COPY --chown=node:node ./admin ./admin
COPY --chown=node:node ./data ./data
COPY package.json ./
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
ARG LOG_LEVEL=debug
ENV LOG_LEVEL=${LOG_LEVEL}
ARG LOG_TO_CONSOLE=true
ENV LOG_TO_CONSOLE=${LOG_TO_CONSOLE}
ARG LOG_PERFORMANCE_SAMPLES=true
ENV LOG_PERFORMANCE_SAMPLES=${LOG_PERFORMANCE_SAMPLES}
ARG PORT=3501
ENV PORT=${PORT}
ARG ENDPOINTS_TLS=false
ENV ENDPOINTS_TLS=${ENDPOINTS_TLS}
ARG SERVER_TYPE=FFA
ENV SERVER_TYPE=${SERVER_TYPE}
ARG SERVER_ROOM=ab-ffa
ENV SERVER_ROOM=${SERVER_ROOM}
ARG SERVER_BOT_NAME=Server
ENV SERVER_BOT_NAME=${SERVER_BOT_NAME}
ARG SERVER_BOT_FLAG=JOLLY
ENV SERVER_BOT_FLAG=${SERVER_BOT_FLAG}
ARG ALLOW_NON_ASCII_USERNAMES=false
ENV ALLOW_NON_ASCII_USERNAMES=${ALLOW_NON_ASCII_USERNAMES}
ARG MODERATION_PANEL=true
ENV MODERATION_PANEL=${MODERATION_PANEL}
ARG MODERATION_PANEL_URL_ROUTE=admin
ENV MODERATION_PANEL_URL_ROUTE=${MODERATION_PANEL_URL_ROUTE}
ARG SU_PASSWORD=
ENV SU_PASSWORD=${SU_PASSWORD}
ARG MAX_PLAYERS_PER_IP=3
ENV MAX_PLAYERS_PER_IP=${MAX_PLAYERS_PER_IP}
ARG BOTS_IP=127.0.0.1
ENV BOTS_IP=${BOTS_IP}
ARG USER_ACCOUNTS=true
ENV USER_ACCOUNTS=${USER_ACCOUNTS}
ARG STATS_SYNC=false
ENV STATS_SYNC=${STATS_SYNC}
ARG AUTH_LOGIN_SERVER_KEY_URL=
ENV AUTH_LOGIN_SERVER_KEY_URL=${AUTH_LOGIN_SERVER_KEY_URL}
ARG PACKETS_FLOODING_AUTOBAN=true
ENV PACKETS_FLOODING_AUTOBAN=${PACKETS_FLOODING_AUTOBAN}
ARG AFK_DISCONNECT_TIMEOUT=
ENV AFK_DISCONNECT_TIMEOUT=${AFK_DISCONNECT_TIMEOUT}
ARG WEBSOCKETS_COMPRESSION=true
ENV WEBSOCKETS_COMPRESSION=${WEBSOCKETS_COMPRESSION}
ENV EXPERIMENTAL_FASTCALL=1
EXPOSE ${PORT}
USER node
CMD [ "node", "./dist/app.js" ]
#
# Building game server image (production).
#
FROM updated-node-alpine as production-image
# Install uWebSockets deps.
RUN apk add --no-cache gcompat
RUN rm -rf /var/cache/apk/*
WORKDIR /app
RUN mkdir logs && chown -R node: logs
RUN mkdir cache && chown -R node: cache
RUN mkdir certs && chown -R node: certs
COPY --from=app-production-build /build/dist ./dist
COPY --from=production-js-dependencies /build/node_modules ./node_modules
COPY --chown=node:node ./admin ./admin
COPY --chown=node:node ./data ./data
COPY package.json ./
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
ARG LOG_LEVEL=info
ENV LOG_LEVEL=${LOG_LEVEL}
ARG LOG_TO_CONSOLE=false
ENV LOG_TO_CONSOLE=${LOG_TO_CONSOLE}
ARG LOG_PERFORMANCE_SAMPLES=true
ENV LOG_PERFORMANCE_SAMPLES=${LOG_PERFORMANCE_SAMPLES}
ARG PORT=3501
ENV PORT=${PORT}
ARG ENDPOINTS_TLS=false
ENV ENDPOINTS_TLS=${ENDPOINTS_TLS}
ARG SERVER_TYPE=FFA
ENV SERVER_TYPE=${SERVER_TYPE}
ARG SERVER_ROOM=ab-ffa
ENV SERVER_ROOM=${SERVER_ROOM}
ARG SERVER_BOT_NAME=Server
ENV SERVER_BOT_NAME=${SERVER_BOT_NAME}
ARG SERVER_BOT_FLAG=JOLLY
ENV SERVER_BOT_FLAG=${SERVER_BOT_FLAG}
ARG ALLOW_NON_ASCII_USERNAMES=false
ENV ALLOW_NON_ASCII_USERNAMES=${ALLOW_NON_ASCII_USERNAMES}
ARG MODERATION_PANEL=true
ENV MODERATION_PANEL=${MODERATION_PANEL}
ARG MODERATION_PANEL_URL_ROUTE=admin
ENV MODERATION_PANEL_URL_ROUTE=${MODERATION_PANEL_URL_ROUTE}
ARG SU_PASSWORD=
ENV SU_PASSWORD=${SU_PASSWORD}
ARG MAX_PLAYERS_PER_IP=3
ENV MAX_PLAYERS_PER_IP=${MAX_PLAYERS_PER_IP}
ARG BOTS_IP=127.0.0.1
ENV BOTS_IP=${BOTS_IP}
ARG USER_ACCOUNTS=true
ENV USER_ACCOUNTS=${USER_ACCOUNTS}
ARG AUTH_LOGIN_SERVER_KEY_URL=
ENV AUTH_LOGIN_SERVER_KEY_URL=${AUTH_LOGIN_SERVER_KEY_URL}
ARG PACKETS_FLOODING_AUTOBAN=true
ENV PACKETS_FLOODING_AUTOBAN=${PACKETS_FLOODING_AUTOBAN}
ARG AFK_DISCONNECT_TIMEOUT=
ENV AFK_DISCONNECT_TIMEOUT=${AFK_DISCONNECT_TIMEOUT}
ARG WEBSOCKETS_COMPRESSION=true
ENV WEBSOCKETS_COMPRESSION=${WEBSOCKETS_COMPRESSION}
ENV EXPERIMENTAL_FASTCALL=1
EXPOSE ${PORT}
USER node
CMD [ "node", "./dist/app.js" ]