Skip to content

Commit 4750d6a

Browse files
committed
[docker] OpenShift support, removing unsupported plugins, correct ab-testing installation
1 parent ca43262 commit 4750d6a

File tree

6 files changed

+67
-13
lines changed

6 files changed

+67
-13
lines changed

Dockerfile-api

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
FROM node:8.16-jessie
22

3-
ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,enterpriseinfo,logger,systemlogs,errorlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,assistant,plugin-upload,times-of-day,compliance-hub,video-intelligence-monetization,alerts,onboarding
3+
ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,enterpriseinfo,logger,systemlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,assistant,times-of-day,compliance-hub,video-intelligence-monetization,alerts,onboarding
4+
# Enterprise Edition:
5+
#ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,drill,funnels,concurrent_users,retention_segments,revenue,logger,systemlogs,populator,reports,crashes,push,block,restrict,users,geo,star-rating,slipping-away-users,compare,server-stats,dashboards,assistant,flows,dbviewer,cohorts,crash_symbolication,crashes-jira,groups,white-labeling,alerts,times-of-day,compliance-hub,onboarding,remote-config,formulas,ab-testing
6+
7+
USER root
48

59
# Core dependencies
610
## Tini
@@ -24,10 +28,10 @@ ENV COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}"
2428
ENV COUNTLY_CONFIG_API_API_HOST="0.0.0.0"
2529

2630
## The files
27-
RUN mkdir /opt/countly && chown 1001:1001 /opt/countly
28-
USER 1001
31+
RUN mkdir /opt/countly && chown 1001:0 /opt/countly
32+
USER 1001:0
2933
WORKDIR /opt/countly
30-
COPY --chown=1001 . .
34+
COPY --chown=1001:0 . .
3135
HEALTHCHECK --start-period=60s CMD curl --fail http://localhost:3001/o/ping || exit 1
3236

3337
## API runtime dependencies
@@ -37,9 +41,12 @@ RUN cp -n api/config.sample.js api/config.js && \
3741
./bin/docker/preinstall.sh
3842

3943
USER root
40-
RUN apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
44+
45+
RUN ./bin/docker/modify.sh && \
46+
chown -R 1001:0 /opt/countly && \
47+
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
4148
apt-get autoremove -y && \
4249
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
4350

44-
USER 1001
51+
USER 1001:0
4552
CMD ["/opt/countly/bin/docker/cmd.sh"]

Dockerfile-frontend

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM node:8.16-jessie
22

3-
ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,enterpriseinfo,logger,systemlogs,errorlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,assistant,plugin-upload,times-of-day,compliance-hub,video-intelligence-monetization,alerts,onboarding
3+
ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,enterpriseinfo,logger,systemlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,assistant,times-of-day,compliance-hub,video-intelligence-monetization,alerts,onboarding
4+
# Enterprise Edition:
5+
#ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,drill,funnels,concurrent_users,retention_segments,revenue,logger,systemlogs,populator,reports,crashes,push,block,restrict,users,geo,star-rating,slipping-away-users,compare,server-stats,dashboards,assistant,flows,dbviewer,cohorts,crash_symbolication,crashes-jira,groups,white-labeling,alerts,times-of-day,compliance-hub,onboarding,remote-config,formulas,ab-testing
46

57
# Core dependencies
68
## Tini
@@ -19,7 +21,7 @@ ENV COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}"
1921
ENV COUNTLY_CONFIG_FRONTEND_WEB_HOST="0.0.0.0"
2022

2123
## The files
22-
RUN mkdir /opt/countly && chown 1001:1001 /opt/countly
24+
RUN mkdir /opt/countly && chown 1001:0 /opt/countly
2325
USER 1001
2426
WORKDIR /opt/countly
2527
COPY --chown=1001 . .
@@ -32,7 +34,10 @@ RUN cp -n frontend/express/public/javascripts/countly/countly.config.sample.js f
3234
./bin/docker/preinstall.sh
3335

3436
USER root
35-
RUN bash /opt/countly/bin/scripts/detect.init.sh && \
37+
38+
RUN ./bin/docker/modify.sh && \
39+
chown -R 1001:0 /opt/countly && \
40+
bash /opt/countly/bin/scripts/detect.init.sh && \
3641
apt-get remove -y git g++ gcc make automake autoconf libtool pkg-config unzip python && \
3742
apt-get autoremove -y && \
3843
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

bin/docker/cmd.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
case "$COUNTLY_CONTAINER" in
66
"api" )
7-
exec /usr/local/bin/node /opt/countly/api/api.js
7+
exec node /opt/countly/api/api.js
88
;;
99

1010
"frontend" )
11-
exec /usr/local/bin/node /opt/countly/frontend/express/app.js
11+
exec node /opt/countly/frontend/express/app.js
1212
;;
1313

1414
* )

bin/docker/modify.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
source /etc/os-release
4+
5+
# Remove plugins unsupported in Docker distribution
6+
rm -rf /opt/countly/plugins/data_migration
7+
rm -rf /opt/countly/plugins/errorlogs
8+
rm -rf /opt/countly/plugins/plugin-upload
9+
rm -rf /opt/countly/plugins/updates
10+
11+
if [ "${COUNTLY_CONTAINER}" != "frontend" ]; then
12+
# Run ab-testing models compilation if it's there
13+
if [ -d /opt/countly/plugins/ab-testing ]; then
14+
if [ "${ID}" == "debian" ]; then
15+
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
16+
tar -xvf Python-3.6.8.tgz
17+
cd Python-3.6.8/
18+
./configure && make && make install
19+
cd ../
20+
rm -rf Python-3.6.8*
21+
apt-get -y install python3-pip
22+
23+
python3.6 -m pip install pandas pystan
24+
cd /opt/countly/plugins/ab-testing/api/bayesian && python3.6 model.py
25+
python3.6 -m pip uninstall -qy pystan
26+
else
27+
yum install -y python36 python36-libs python36-devel python36-pip centos-release-scl devtoolset-7-gcc-c++
28+
source /opt/rh/devtoolset-7/enable
29+
export CC=/opt/rh/devtoolset-7/root/usr/bin/gcc
30+
export CXX=/opt/rh/devtoolset-7/root/usr/bin/g++
31+
python3 -m pip install pandas pystan
32+
cd /opt/countly/plugins/ab-testing/api/bayesian && python3 model.py
33+
python3 -m pip uninstall -qy pystan
34+
yum remove -y python36-devel centos-release-scl devtoolset-7-gcc-c++
35+
fi
36+
fi
37+
fi
38+

bin/docker/postinstall.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ else
2020

2121
while read -r plugin; do
2222
echo "[docker] Installing ${plugin}:"
23-
/usr/local/bin/node "/opt/countly/plugins/$plugin/install.js"
23+
node "/opt/countly/plugins/$plugin/install.js"
2424
echo "[docker] Done installing ${plugin}."
2525
done <<< "$a"
2626

bin/docker/preinstall.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
22

3+
source /etc/os-release
4+
35
while IFS= read -r -d '' plugin
46
do
57
echo "Installing $plugin..."
68
(cd "$plugin" && HOME=/tmp npm install)
79
echo "done"
8-
done < <(find /opt/countly/plugins -mindepth 1 -maxdepth 1 -type d -print0)
10+
done < <(find /opt/countly/plugins -mindepth 1 -maxdepth 1 -type d -print0)
11+
12+
export CXX="" && export CC=""

0 commit comments

Comments
 (0)