-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile.release
164 lines (145 loc) · 5.42 KB
/
Dockerfile.release
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
#
# Copyright 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 ubuntu:bionic
ARG BUILD_DATE=unknown
ARG KOPANO_VERSION=8.7.82.61
ARG KOPANO_CHANNEL=community
ARG VCS_REF=unknown
LABEL \
maintainer="[email protected]" \
org.label-schema.name="Kopano Grapi container" \
org.label-schema.description="Container for running the Kopano Rest API" \
org.label-schema.url="https://kopano.io" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://stash.kopano.io/projects/KC/repos/grapi/browse" \
org.label-schema.version=$KOPANO_VERSION \
org.label-schema.schema-version="1.0"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y \
curl \
gnupg \
net-tools \
ca-certificates \
locales \
dpkg-dev
ENV EXE=kopano-grapi
ENV KOPANO_GRAPI_USER=nobody
ENV KOPANO_GRAPI_GROUP=nogroup
ENV KOPANO_GRAPI_SOCKET_PATH=/run/kopano-grapi
ENV KOPANO_GRAPI_KOPANO_SERVER_URI=file:///run/kopano/server.sock
ENV KOPANO_GRAPI_PERSISTENCY_PATH=/var/lib/kopano-grapi
ENV KOPANO_GRAPI_NUM_WORKERS=""
ENV ARGS=""
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
# Locale.
RUN locale-gen --no-purge en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# Tini for sane Docker.
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
RUN set -ex && \
for key in \
595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 ; \
do \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
done
RUN gpg --verify /tini.asc && chmod +x /tini
ENTRYPOINT ["/tini", "-g", "--", "docker-entrypoint.sh"]
# Gosu for sane su.
ENV GOSU_VERSION 1.11
ADD https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64 /gosu
ADD https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc /gosu.asc
RUN set -ex && \
for key in \
B42F6819007F00F88E364FD4036A9C25BF357DD4 ; \
do \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
done
RUN gpg --verify /gosu.asc && chmod +x /gosu
RUN /gosu nobody true
# Kopano base dependencies.
ENV KOPANO_VERSION=${KOPANO_VERSION}
ENV KOPANO_CHANNEL=${KOPANO_CHANNEL}
RUN sh -ex && BUILD_DATE=${BUILD_DATE} mkdir -p /srv/download && \
cd /srv/download && \
curl -sSL https://download.kopano.io/${KOPANO_CHANNEL}/core:/core-${KOPANO_VERSION}-Ubuntu_18.04-amd64.tar.gz | \
tar -C /srv/download --strip 1 -vxzf - \
&& dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz \
&& echo '\
deb [trusted=yes] file:/srv/download ./' > /etc/apt/sources.list.d/kopano.list \
&& echo "${KOPANO_VERSION} (${KOPANO_CHANNEL})" > /srv/.kopano-version \
&& apt-get update
# Install Grapi.
RUN apt-get install -y \
kopano-grapi \
python3-prometheus-client \
&& dpkg -s kopano-grapi | grep Version | awk '{split($0,a,": "); print a[2]}' > /srv/.grapi-version \
&& dpkg -s python3-mapi | grep Version | awk '{split($0,a,": "); print a[2]}' > /srv/.mapi-version
# Cleanup stuff we do no need.
RUN rm -rf \
/srv/download \
apt-get clean && \
apt-get -y remove --purge gnupg dpkg-dev && \
apt-get -y autoremove --purge && \
rm -rf /var/lib/apt/lists/*
# Remove documentation.
RUN rm -rf \
/usr/share/doc/* \
/usr/share/man/* \
/usr/share/groff/* \
/usr/share/info/*
# Add Docker specific runtime setup functions.
RUN mkdir /etc/defaults && echo -e '\
setup_env() { \n\
export socket_path=${KOPANO_GRAPI_SOCKET_PATH} \n\
export server_socket=${KOPANO_GRAPI_KOPANO_SERVER_URI} \n\
export persistency_path=${KOPANO_GRAPI_PERSISTENCY_PATH} \n\
if [ -z "${KOPANO_GRAPI_NUM_WORKERS}" ]; then \n\
export num_workers=$(cat /proc/cpuinfo | grep processor | wc -l) \n\
else \n\
export num_workers=${KOPANO_GRAPI_NUM_WORKERS} \n\
fi \n\
if [ ! -d "${socket_path}" ]; then \n\
mkdir -p "${socket_path}" && chown ${KOPANO_GRAPI_USER}:${KOPANO_GRAPI_GROUP} "${socket_path}" \n\
fi \n\
if [ ! -d "${persistency_path}" ]; then \n\
mkdir -p "${persistency_path}" && chown ${KOPANO_GRAPI_USER}:${KOPANO_GRAPI_GROUP} "${persistency_path}" \n\
fi \n\
export prometheus_multiproc_dir=/tmp/prometheus && \n\
mkdir /tmp/prometheus && \n\
chown ${KOPANO_GRAPI_USER}:${KOPANO_GRAPI_GROUP} /tmp/prometheus \n\
}\n\
setup_env\n\
' > /etc/defaults/docker-env
EXPOSE 6060/tcp
WORKDIR /srv/
COPY \
scripts/docker-entrypoint.sh \
scripts/healthcheck.sh \
/usr/local/bin/
RUN chmod 755 /usr/local/bin/*.sh
CMD [ \
"kopano-grapi", \
"--help" \
]
# Health check support is cool too.
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
CMD healthcheck.sh || exit 1