-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
71 lines (59 loc) · 1.97 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
#!/bin/sh
#
# Copyright 2018-2019 Kopano and its licensors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3 or
# later, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
FROM alpine:3.12
LABEL maintainer="[email protected]"
# Expose ports.
EXPOSE 8778
EXPOSE 6778
# Define basic environment variables.
ENV EXE=kwmserverd
ENV KWMSERVERD_LISTEN=0.0.0.0:8778
ENV KWMSERVERD_ADMIN_TOKENS_KEY_FILE=kwmserverd_admin_tokens_key
# Defaults which can be overwritten.
ENV ARGS=""
WORKDIR /var/lib/kwmserverd-docker
# Copy Docker specific scripts and ensure they are executable.
COPY \
scripts/docker-entrypoint.sh \
scripts/healthcheck.sh \
/usr/local/bin/
RUN chmod 755 /usr/local/bin/*.sh
# Add Docker specific runtime setup functions.
RUN mkdir /etc/defaults && echo $'\
setup_secrets() { \n\
local adminTokensFile="/run/secrets/${KWMSERVERD_ADMIN_TOKENS_KEY_FILE}" \n\
if [ -f "${adminTokensFile}" ]; then \n\
export KWMSERVERD_ADMIN_TOKENS_KEY="${adminTokensFile}" \n\
fi \n\
}\n\
setup_secrets\n\
' > /etc/defaults/docker-env
# Add project resources.
COPY docs/* /var/lib/kwmserverd-docker/docs/
COPY www/* /var/lib/kwmserverd-docker/www/
# Add project main binary.
COPY bin/kwmserverd /usr/local/bin/${EXE}
# Run as nobody by default is always a good idea.
USER nobody
ENTRYPOINT ["docker-entrypoint.sh"]
CMD [ \
"kwmserverd", \
"serve" \
]
# Health check support is cool too.
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
CMD healthcheck.sh --hostname="${KWMSERVERD_LISTEN}" || exit 1