-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
147 lines (123 loc) · 5.03 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
# GPLv3 License
#
# The container produced with this file contains all
# GrimoireLab libraries and executables, and is configured
# for running mordred by default
#
FROM debian:buster-slim
MAINTAINER Kiwix <contact@kiwix.org>
ENV DEBIAN_FRONTEND=noninteractive
ENV DEPLOY_USER=grimoirelab
ENV DEPLOY_USER_DIR=/home/${DEPLOY_USER}
ENV DIST_SCRIPT=/usr/local/bin/build_grimoirelab \
LOGS_DIR=/logs \
DIST_DIR=/dist
ENV REL_FILE=/releases.cfg
ENV ES=elasticsearch-6.1.4
ENV KB_VERSION=6.1.4-1
ENV KB_TAG=community-v${KB_VERSION}
ENV KB=kibiter-${KB_VERSION}
ENV KB_DIR=${KB}-linux-x86_64
ENV GITHUB_TOKEN=xxx
ENV GET="wget -q"
ENV TRUNCATE_LOGS ""
# install dependencies
RUN apt-get update && \
apt-get -y install --no-install-recommends \
bash locales \
gcc \
git git-core \
pandoc \
python3 \
python3-pip \
python3-venv \
python3-dev \
python3-gdbm \
mariadb-client \
unzip curl wget sudo ssh \
openjdk-11-jdk-headless \
net-tools \
mariadb-server cloc \
logrotate cron \
&& \
apt-get clean && \
find /var/lib/apt/lists -type f -delete
# Initial user and dirs
RUN useradd ${DEPLOY_USER} --create-home --shell /bin/bash ; \
echo "${DEPLOY_USER} ALL=NOPASSWD: ALL" >> /etc/sudoers ; \
mkdir ${DIST_DIR} ; chown -R ${DEPLOY_USER}:${DEPLOY_USER} ${DIST_DIR} ; \
mkdir ${LOGS_DIR} ; chown -R ${DEPLOY_USER}:${DEPLOY_USER} ${LOGS_DIR}
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
LANG=C.UTF-8
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
# Add script to create distributable packages
COPY config/releases.cfg ${REL_FILE}
COPY bin/build_grimoirelab ${DIST_SCRIPT}
RUN chmod 755 ${DIST_SCRIPT}
# Add packages (should be in dist, when building)
COPY dist/* ${DIST_DIR}/
# Unbuffered output for Python, so that we see messages as they are produced
ENV PYTHONUNBUFFERED 0
# Install GrimoireLab from packages in DIST_DIR
RUN ${DIST_SCRIPT} --build --install --install_system --distdir ${DIST_DIR} --relfile ${REL_FILE}
# Install ElasticSearch
RUN ${GET} https://artifacts.elastic.co/downloads/elasticsearch/${ES}.deb && \
${GET} https://artifacts.elastic.co/downloads/elasticsearch/${ES}.deb.sha512 && \
sudo dpkg -i ${ES}.deb && \
rm ${ES}.deb ${ES}.deb.sha512
RUN sed -e "/MAX_MAP_COUNT=/s/^/#/g" -i /etc/init.d/elasticsearch && \
echo "http.host: 0.0.0.0" >> /etc/elasticsearch/elasticsearch.yml && \
echo "cluster.routing.allocation.disk.watermark.flood_stage: 99.9%" >> /etc/elasticsearch/elasticsearch.yml && \
echo "cluster.routing.allocation.disk.watermark.low: 99.9%" >> /etc/elasticsearch/elasticsearch.yml && \
echo "cluster.routing.allocation.disk.watermark.high: 99.9%" >> /etc/elasticsearch/elasticsearch.yml
EXPOSE 9200
# Configure MariaDB
RUN echo "mysqld_safe &" > /tmp/config && \
echo "mysqladmin --silent --wait=30 ping || exit 1" >> /tmp/config && \
echo "mysql -e 'CREATE USER grimoirelab;'" >> /tmp/config && \
echo "mysql -e 'GRANT ALL PRIVILEGES ON *.* TO \"grimoirelab\"@\"%\" WITH GRANT OPTION;'" >> /tmp/config && \
bash /tmp/config && \
rm -f /tmp/config && \
sed -e "/bind-address/s/^/#/g" -i /etc/mysql/mariadb.conf.d/50-server.cnf
EXPOSE 3306
USER ${DEPLOY_USER}
WORKDIR ${DEPLOY_USER_DIR}
# Install Kibana (as DEPLOY_USER)
RUN ${GET} https://github.com/grimoirelab/kibiter/releases/download/${KB_TAG}/${KB_DIR}.tar.gz && \
tar xzf ${KB_DIR}.tar.gz && \
rm ${KB_DIR}.tar.gz && \
sed -e "s|^#server.host: .*$|server.host: 0.0.0.0|" -i ${KB_DIR}/config/kibana.yml && \
rm -rf ${KB_DIR}/src/ui/public/images ${KB_DIR}/src/ui/public/assets/favicons
# Unauthorize devTools access
RUN sed -e "s/ 'devTools',//g" -i ${KB_DIR}/src/core_plugins/kibana/index.js
COPY images ${KB_DIR}/src/ui/public/images
COPY favicons ${KB_DIR}/src/ui/public/assets/favicons
# Run Kibana until optimization is done, to avoid optimizing every
# time the image is run
RUN ${KB_DIR}/bin/kibana 2>&1 | grep -m 1 "Optimization of .* complete in .* seconds"
EXPOSE 5601
USER root
# Add default mordred configuration files
COPY config/mordred-infra.cfg /infra.cfg
COPY config/mordred-dashboard.cfg /dashboard.cfg
COPY config/mordred-project.cfg /project.cfg
COPY config/mordred-override.cfg /override.cfg
COPY config/orgs.json /orgs.json
COPY config/projects.json /projects.json
COPY config/identities.yaml /identities.yaml
COPY config/menu.yaml /menu.yaml
COPY config/aliases.json /aliases.json
COPY config/dashboard_overview.json /dashboard_overview.json
COPY config/logrotate /etc/logrotate.d/metrics
COPY bin/truncate-logs.sh /etc/cron.hourly/truncate-logs
COPY bin/entrypoint.sh /entrypoint.sh
RUN sudo chmod 755 /entrypoint.sh
#VOLUME /var/lib/elasticsearch
# Entrypoint
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "-c", "/infra.cfg", "/dashboard.cfg", "/project.cfg", "/override.cfg"]