Skip to content

Commit

Permalink
[docker] Updating builds to node 10 + various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iartem committed Mar 13, 2020
1 parent 32c584f commit ac8ae1c
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 82 deletions.
76 changes: 41 additions & 35 deletions Dockerfile-api
Original file line number Diff line number Diff line change
@@ -1,52 +1,58 @@
FROM node:8.16-jessie
FROM node:10.19-jessie

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
# Enterprise Edition:
#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

EXPOSE 3001
HEALTHCHECK --start-period=60s CMD curl --fail http://localhost:3001/o/ping || exit 1

USER root

# Core dependencies
## Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

ENTRYPOINT ["/tini", "-v", "--"]

RUN apt-get update && apt-get -y install sendmail sqlite3

# Required by push plugin
RUN git clone https://github.com/nghttp2/nghttp2.git /tmp/nghttp2 && \
cd /tmp/nghttp2 && \
git checkout tags/v1.30.0 && \
export CFLAGS="-g -O2 -fPIC" && export CPPFLAGS="-fPIC" && autoreconf -i && automake && autoconf && ./configure --disable-examples --disable-app && make && make install
ENV COUNTLY_CONTAINER="api" \
COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}" \
COUNTLY_CONFIG_API_API_HOST="0.0.0.0" \
TINI_VERSION="0.18.0"

# Setup Countly
ENV COUNTLY_CONTAINER="api"
ENV COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}"
ENV COUNTLY_CONFIG_API_API_HOST="0.0.0.0"

## The files
RUN mkdir /opt/countly && chown 1001:0 /opt/countly
USER 1001:0
WORKDIR /opt/countly
COPY --chown=1001:0 . .
HEALTHCHECK --start-period=60s CMD curl --fail http://localhost:3001/o/ping || exit 1

## API runtime dependencies
RUN cp -n api/config.sample.js api/config.js && \
cp -n frontend/express/config.sample.js frontend/express/config.js && \
COPY . .

RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" && \
dpkg -i /tmp/tini.deb && \
git clone https://github.com/nghttp2/nghttp2.git /tmp/nghttp2 --single-branch --branch=v1.30.0 --depth=1 && \
(cd /tmp/nghttp2; \
export CFLAGS="-g -O2 -fPIC" && export CPPFLAGS="-fPIC" && autoreconf -i && automake && autoconf && ./configure --disable-examples --disable-app && make && make install) && \
\
# modify standard distribution
apt-get update && apt-get install -y sqlite3 && \
./bin/docker/modify.sh && \
\
# preinstall
cp -n ./api/config.sample.js ./api/config.js && \
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
HOME=/tmp npm install && \
./bin/docker/preinstall.sh

USER root

RUN ./bin/docker/modify.sh && \
chown -R 1001:0 /opt/countly && \
./bin/docker/preinstall.sh && \
bash /opt/countly/bin/scripts/detect.init.sh && \
\
# cleanup & chown
npm remove -y mocha nyc should supertest && \
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
apt-get autoremove -y && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
apt-get -y install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
rm -rf /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm && \
\
# temporary to remove npm bug message
mkdir /.npm && chown -R 1001:0 /.npm && \
\
chown -R 1001:0 /opt/countly && \
chmod -R g=u /opt/countly


USER 1001:0

ENTRYPOINT ["/usr/bin/tini", "-v", "--"]

CMD ["/opt/countly/bin/docker/cmd.sh"]
8 changes: 5 additions & 3 deletions Dockerfile-centos-api
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM centos/nodejs-8-centos7
FROM centos/nodejs-10-centos7

#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
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
# Enterprise Edition:
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
#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

EXPOSE 3001
HEALTHCHECK --start-period=60s CMD curl --fail http://localhost:3001/o/ping || exit 1

USER root
Expand Down Expand Up @@ -34,6 +35,7 @@ RUN curl -s -L -o /tmp/tini.rpm "https://github.com/krallin/tini/releases/downlo
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
HOME=/tmp npm install && \
./bin/docker/preinstall.sh && \
bash /opt/countly/bin/scripts/detect.init.sh && \
\
# cleanup & chown
npm remove -y mocha nyc should supertest && \
Expand Down
10 changes: 7 additions & 3 deletions Dockerfile-centos-frontend
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM centos/nodejs-8-centos7
FROM centos/nodejs-10-centos7

#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
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
# Enterprise Edition:
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
#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

EXPOSE 6001
HEALTHCHECK --start-period=120s CMD curl --fail http://localhost:6001/ping || exit 1

USER root
Expand All @@ -30,12 +31,15 @@ RUN curl -s -L -o /tmp/tini.rpm "https://github.com/krallin/tini/releases/downlo
cp -n ./api/config.sample.js ./api/config.js && \
HOME=/tmp npm install && \
./bin/docker/preinstall.sh && \
bash /opt/countly/bin/scripts/detect.init.sh && \
countly update sdk-web && \
\
# cleanup & chown
npm remove -y mocha nyc should supertest && \
rm -rf /opt/app-root/src/.npm && \
yum remove -y git gcc make automake autoconf makedepend zlib-devel libxml2-devel python-setuptools openssl-devel && \
yum -y autoremove && \
yum -y install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc && \
yum clean all && \
rm -rf /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* && \
chown -R 1001:0 /opt/countly && \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile-core
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN useradd -r -M -U -d /opt/countly -s /bin/false countly && \
gcc-4.8 g++-4.8 make binutils autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev \
libevent-dev libjansson-dev libjemalloc-dev cython python3-dev python-setuptools && \
# node
wget -qO- https://deb.nodesource.com/setup_8.x | bash - && \
wget -qO- https://deb.nodesource.com/setup_10.x | bash - && \
# data_migration (mongo clients)
wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | apt-key add - && \
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.6.list && \
Expand Down Expand Up @@ -80,6 +80,7 @@ RUN useradd -r -M -U -d /opt/countly -s /bin/false countly && \
# cleanup
apt-get -y remove build-essential libkrb5-dev git sqlite3 wget \
gcc-4.8 g++-4.8 gcc g++ make binutils autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson-dev libjemalloc-dev cython python3-dev python-setuptools && \
apt-get -y install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* ~/.npm

Expand Down
78 changes: 44 additions & 34 deletions Dockerfile-frontend
Original file line number Diff line number Diff line change
@@ -1,47 +1,57 @@
FROM node:8.16-jessie
FROM node:10.19-jessie

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
# Enterprise Edition:
#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

# Core dependencies
## Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

ENTRYPOINT ["/tini", "-v", "--"]
EXPOSE 6001
HEALTHCHECK --start-period=120s CMD curl --fail http://localhost:6001/ping || exit 1

RUN apt-get update && apt-get -y install sendmail && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
USER root

# Setup Countly
ENV COUNTLY_CONTAINER="frontend"
ENV COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}"
ENV COUNTLY_CONFIG_FRONTEND_WEB_HOST="0.0.0.0"
# Core dependencies
## Tini
ENV COUNTLY_CONTAINER="frontend" \
COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}" \
COUNTLY_CONFIG_FRONTEND_WEB_HOST="0.0.0.0" \
TINI_VERSION="0.18.0"

## The files
RUN mkdir /opt/countly && chown 1001:0 /opt/countly
USER 1001
WORKDIR /opt/countly
COPY --chown=1001 . .
HEALTHCHECK --start-period=120s CMD curl --fail http://localhost:6001/ping || exit 1

RUN cp -n frontend/express/public/javascripts/countly/countly.config.sample.js frontend/express/public/javascripts/countly/countly.config.js && \
cp -n frontend/express/config.sample.js frontend/express/config.js && \
cp -n api/config.sample.js api/config.js && \
COPY . .

RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" && \
dpkg -i /tmp/tini.deb && \
\
# modify standard distribution
apt-get update && apt-get install -y sqlite3 && \
./bin/docker/modify.sh && \
\
# preinstall
cp -n ./api/config.sample.js ./api/config.js && \
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
cp -n ./frontend/express/public/javascripts/countly/countly.config.sample.js ./frontend/express/public/javascripts/countly/countly.config.js && \
HOME=/tmp npm install && \
./bin/docker/preinstall.sh

USER root

RUN ./bin/docker/modify.sh && \
chown -R 1001:0 /opt/countly && \
./bin/docker/preinstall.sh && \
bash /opt/countly/bin/scripts/detect.init.sh && \
apt-get remove -y git g++ gcc make automake autoconf libtool pkg-config unzip python && \
countly update sdk-web && \
\
# cleanup & chown
npm remove -y mocha nyc should supertest && \
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
apt-get autoremove -y && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
apt-get -y install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
rm -rf /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm && \
\
# temporary to remove npm bug message
mkdir /.npm && chown -R 1001:0 /.npm && \
\
chown -R 1001:0 /opt/countly && \
chmod -R g=u /opt/countly


USER 1001:0

ENTRYPOINT ["/usr/bin/tini", "-v", "--"]

USER 1001
RUN countly update sdk-web
CMD ["/opt/countly/bin/docker/cmd.sh"]
CMD ["/opt/countly/bin/docker/cmd.sh"]
5 changes: 1 addition & 4 deletions bin/countly.install_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ if [[ "$GLIBC_VERSION" != "2.25" ]]; then
fi

#install mongodb
if [ "$INSIDE_DOCKER_NOMONGO" != "1" ]
then
bash "$DIR/scripts/mongodb.install.sh"
fi
bash "$DIR/scripts/mongodb.install.sh"

bash "$DIR/scripts/detect.init.sh"

Expand Down
19 changes: 18 additions & 1 deletion bin/docker/modify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@ fi
if [ "${COUNTLY_CONTAINER}" != "frontend" ]; then
# Run ab-testing models compilation if it's there
if [ -d /opt/countly/plugins/ab-testing ]; then
if [ "${ID}" == "debian" ] || [ "${ID}" == "ubuntu" ]; then
if [ "${ID}" == "debian" ]; then
cd /tmp
apt-get -y install wget
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
tar -xzf Python-3.6.8.tgz
cd Python-3.6.8/
./configure && make && make install

update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3 2

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

python3 -m pip install pandas
python3 -m pip install pystan
python3 "/opt/countly/plugins/ab-testing/api/bayesian/model.py"

elif [ "${ID}" == "ubuntu" ]; then
apt-get -y install gcc g++ build-essential python3-dev python3-pip libncurses*-dev libsqlite3-dev libreadline6-dev libgdbm-dev zlib1g-dev libbz2-dev sqlite3 tk-dev zip libssl-dev libncurses5-dev python-lzma liblzma-dev tk8.5-dev
python3 -m pip install pandas pystan
cd /opt/countly/plugins/ab-testing/api/bayesian && python3 model.py
Expand Down
2 changes: 1 addition & 1 deletion bin/docker/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ else
echo "[docker] Done installing ${plugin}."
done <<< "$a"

(cd /opt/countly && npx grunt dist-all && npm prune --production)
(cd /opt/countly && npx grunt dist-all && npm prune --production && npm cache clean --force)

fi

0 comments on commit ac8ae1c

Please sign in to comment.