-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
108 lines (95 loc) · 3.72 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
#!/bin/sh
#
# Copyright 2017-2020 Kopano and its licensors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM alpine:3.12
LABEL maintainer="development@kopano.io"
RUN apk add --no-cache \
su-exec=0.2-r0
# Expose ports.
EXPOSE 8777
EXPOSE 6777
# Define basic environment variables.
ENV EXE=konnectd
ENV KONNECTD_LISTEN=0.0.0.0:8777
ENV KONNECTD_IDENTIFIER_CLIENT_PATH=/var/lib/konnectd-docker/identifier-webapp
ENV KONNECTD_DOCKER_SECRETS_PATH=/run/secrets
ENV KONNECTD_SIGNING_PRIVATE_KEY_FILE=konnectd_signing_private_key
ENV KONNECTD_ENCRYPTION_SECRET_FILE=konnectd_encryption_secret
ENV KONNECTD_KOPANO_SERVER_USERNAME_FILE=konnectd_kopano_server_username
ENV KONNECTD_KOPANO_SERVER_PASSWORD_FILE=konnectd_kopano_server_password
ENV KONNECTD_LDAP_BIND_DN_FILE=konnectd_ldap_bind_dn
ENV KONNECTD_LDAP_BIND_PASSWORD_FILE=konnectd_ldap_bind_password
# Defaults which can be overwritten.
ENV KOPANO_SERVER_DEFAULT_URI=file:///run/kopano/server.sock
ENV KOPANO_SERVER_USERNAME=""
ENV KOPANO_SERVER_PASSWORD=""
ENV KOPANO_SERVER_SESSION_TIMEOUT=""
ENV LDAP_URI=""
ENV LDAP_BINDDN=""
ENV LDAP_BINDPW=""
ENV ARGS=""
# User and group defaults.
ENV KONNECTD_USER=nobody
ENV KONNECTD_GROUP=nogroup
WORKDIR /var/lib/konnectd-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 signingPrivateKeyFile="${KONNECTD_DOCKER_SECRETS_PATH}/${KONNECTD_SIGNING_PRIVATE_KEY_FILE}" \n\
if [ -f "${signingPrivateKeyFile}" ]; then \n\
export KONNECTD_SIGNING_PRIVATE_KEY="${signingPrivateKeyFile}" \n\
fi \n\
local encryptionSecretFile="${KONNECTD_DOCKER_SECRETS_PATH}/${KONNECTD_ENCRYPTION_SECRET_FILE}" \n\
if [ -f "${encryptionSecretFile}" ]; then \n\
export KONNECTD_ENCRYPTION_SECRET="${encryptionSecretFile}" \n\
fi \n\
local kopanoServerUsernameFile="${KONNECTD_DOCKER_SECRETS_PATH}/${KONNECTD_KOPANO_SERVER_USERNAME_FILE}" \n\
if [ -f "${kopanoServerUsernameFile}" ]; then \n\
export KOPANO_SERVER_USERNAME="$(cat ${kopanoServerUsernameFile})" \n\
fi \n\
local kopanoServerPasswordFile="${KONNECTD_DOCKER_SECRETS_PATH}/${KONNECTD_KOPANO_SERVER_PASSWORD_FILE}" \n\
if [ -f "${kopanoServerPasswordFile}" ]; then \n\
export KOPANO_SERVER_PASSWORD="$(cat ${kopanoServerPasswordFile})" \n\
fi \n\
local ldapBindDNFile="${KONNECTD_DOCKER_SECRETS_PATH}/${KONNECTD_LDAP_BIND_DN_FILE}" \n\
if [ -f "${ldapBindDNFile}" ]; then \n\
export LDAP_BINDDN="$(cat ${ldapBindDNFile})" \n\
fi \n\
local ldapBindPasswordFile="${KONNECTD_DOCKER_SECRETS_PATH}/${KONNECTD_LDAP_BIND_PASSWORD_FILE}" \n\
if [ -f "${ldapBindPasswordFile}" ]; then \n\
export LDAP_BINDPW="$(cat ${ldapBindPasswordFile})" \n\
fi \n\
}\n\
setup_secrets\n\
' > /etc/defaults/docker-env
# Add project resources.
COPY identifier/build /var/lib/konnectd-docker/identifier-webapp
# Add project main binary.
COPY bin/konnectd /usr/local/bin/${EXE}
ENTRYPOINT ["docker-entrypoint.sh"]
CMD [ \
"konnectd", \
"--help" \
]
# Health check support is cool too.
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
CMD healthcheck.sh --hostname="${KONNECTD_LISTEN}" || exit 1