Skip to content

Commit 476e9cc

Browse files
authored
Merge pull request #1056 from Countly/feature/new-whale
Feature/new whale
2 parents 70e1bb0 + 36cfef7 commit 476e9cc

File tree

44 files changed

+1625
-811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1625
-811
lines changed

.dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.git
22
.github
3-
.DS_Store
3+
.DS_Store
4+
.Dockerfile*

.eslintignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ frontend/express/public/javascripts/min/**
55
frontend/express/public/javascripts/utils/**
66
frontend/express/public/javascripts/visualization/**
77
frontend/express/public/themes/**
8+
frontend/express/public/sdk/**
89
plugins/*/frontend/public/*
910
plugins/*/frontend/public/javascripts/*
1011
bin/scripts/nghttp2/*
1112
plugins/push/api/parts/apn/*
1213

1314
!plugins/*/frontend/public/javascripts
14-
!plugins/*/frontend/public/javascripts/countly.models.js
15-
!plugins/*/frontend/public/javascripts/countly.views.js
15+
!plugins/*/frontend/public/javascripts/countly.*.js

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@
194194
"frontend/express/libs/*.js",
195195
"plugins/pluginManager.js",
196196
"plugins/*/api/**/*.js",
197-
"plugins/*/frontend/*.js"
197+
"plugins/*/frontend/*.js",
198+
"plugins/*/extend/*.js"
198199
],
199200
"env": {
200201
"es6": true,

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: nodejs
22
dist: trusty
3-
node_js: "8"
3+
node_js: "10"
44
env:
55
global:
6-
- MONGODB=3.6.6
6+
- MONGODB=4.0.12
77
- secure: ZXdUMP+8Nk9Kd5nX31D/DIB1t2xlJd+T4W7umWjwpy+KPA9d1W1OhUG6V2Gpv3PsJf+UtMosgZsywcLFVG4l/WcjAhs3c9pegW5ZRYAEfVjkk7aHhWQGvj5DID8iAAxs91Mm8LwJ43o68x+XN6746zArPqcVzQltDunJ0G3gfh8=
88
branches:
99
except:

Dockerfile-api

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM node:8.16-jessie
2+
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
4+
5+
# Core dependencies
6+
## Tini
7+
ENV TINI_VERSION v0.18.0
8+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
9+
RUN chmod +x /tini
10+
11+
ENTRYPOINT ["/tini", "-v", "--"]
12+
13+
RUN apt-get update && apt-get -y install sendmail sqlite3
14+
15+
# Required by push plugin
16+
RUN git clone https://github.com/nghttp2/nghttp2.git /tmp/nghttp2 && \
17+
cd /tmp/nghttp2 && \
18+
git checkout tags/v1.30.0 && \
19+
export CFLAGS="-g -O2 -fPIC" && export CPPFLAGS="-fPIC" && autoreconf -i && automake && autoconf && ./configure --disable-examples --disable-app && make && make install
20+
21+
# Setup Countly
22+
ENV COUNTLY_CONTAINER="api"
23+
ENV COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}"
24+
ENV COUNTLY_CONFIG_API_API_HOST="0.0.0.0"
25+
26+
## The files
27+
RUN mkdir /opt/countly && chown 1001:1001 /opt/countly
28+
USER 1001
29+
WORKDIR /opt/countly
30+
COPY --chown=1001 . .
31+
HEALTHCHECK --start-period=60s CMD curl --fail http://localhost:3001/o/ping || exit 1
32+
33+
## API runtime dependencies
34+
RUN cp -n api/config.sample.js api/config.js && \
35+
cp -n frontend/express/config.sample.js frontend/express/config.js && \
36+
HOME=/tmp npm install && \
37+
./bin/docker/preinstall.sh
38+
39+
USER root
40+
RUN apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
41+
apt-get autoremove -y && \
42+
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
43+
44+
USER 1001
45+
CMD ["/opt/countly/bin/docker/cmd.sh"]

Dockerfile-frontend

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM node:8.16-jessie
2+
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
4+
5+
# Core dependencies
6+
## Tini
7+
ENV TINI_VERSION v0.18.0
8+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
9+
RUN chmod +x /tini
10+
11+
ENTRYPOINT ["/tini", "-v", "--"]
12+
13+
RUN apt-get update && apt-get -y install sendmail && \
14+
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
15+
16+
# Setup Countly
17+
ENV COUNTLY_CONTAINER="frontend"
18+
ENV COUNTLY_DEFAULT_PLUGINS="${COUNTLY_PLUGINS}"
19+
ENV COUNTLY_CONFIG_FRONTEND_WEB_HOST="0.0.0.0"
20+
21+
## The files
22+
RUN mkdir /opt/countly && chown 1001:1001 /opt/countly
23+
USER 1001
24+
WORKDIR /opt/countly
25+
COPY --chown=1001 . .
26+
HEALTHCHECK --start-period=120s CMD curl --fail http://localhost:6001/ping || exit 1
27+
28+
RUN cp -n frontend/express/public/javascripts/countly/countly.config.sample.js frontend/express/public/javascripts/countly/countly.config.js && \
29+
cp -n frontend/express/config.sample.js frontend/express/config.js && \
30+
cp -n api/config.sample.js api/config.js && \
31+
HOME=/tmp npm install && \
32+
./bin/docker/preinstall.sh
33+
34+
USER root
35+
RUN bash /opt/countly/bin/scripts/detect.init.sh && \
36+
apt-get remove -y git g++ gcc make automake autoconf libtool pkg-config unzip python && \
37+
apt-get autoremove -y && \
38+
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
39+
40+
USER 1001
41+
RUN countly update sdk-web
42+
CMD ["/opt/countly/bin/docker/cmd.sh"]

bin/docker/cmd.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
/opt/countly/bin/docker/postinstall.sh
4+
5+
case "$COUNTLY_CONTAINER" in
6+
"api" )
7+
exec /usr/local/bin/node /opt/countly/api/api.js
8+
;;
9+
10+
"frontend" )
11+
npx grunt dist-all
12+
exec /usr/local/bin/node /opt/countly/frontend/express/app.js
13+
;;
14+
15+
* )
16+
# Run custom command. Thanks to this line we can still use
17+
# "docker run our_image /bin/bash" and it will work
18+
exec $CMD ${@:2}
19+
;;
20+
esac
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: countly-api
5+
spec:
6+
ports:
7+
- port: 3001
8+
protocol: TCP
9+
targetPort: 3001
10+
selector:
11+
app: countly-api
12+
type: NodePort

bin/docker/k8s/countly-api.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: countly-api-deployment
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: countly-api
9+
replicas: 2
10+
template:
11+
metadata:
12+
labels:
13+
app: countly-api
14+
spec:
15+
containers:
16+
- name: countly-api
17+
image: countly/api:19.08.1
18+
ports:
19+
- containerPort: 3001
20+
readinessProbe:
21+
httpGet:
22+
path: /o/ping
23+
port: 3001
24+
initialDelaySeconds: 30
25+
periodSeconds: 5
26+
env:
27+
- name: COUNTLY_PLUGINS
28+
value: "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"
29+
- name: COUNTLY_CONFIG_API_FILESTORAGE
30+
value: "gridfs"
31+
- name: COUNTLY_CONFIG_API_MONGODB
32+
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
33+
- name: COUNTLY_CONFIG_FRONTEND_MONGODB
34+
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: countly-frontend
5+
spec:
6+
ports:
7+
- port: 6001
8+
protocol: TCP
9+
targetPort: 6001
10+
selector:
11+
app: countly-frontend
12+
type: NodePort

bin/docker/k8s/countly-frontend.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: countly-frontend-deployment
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: countly-frontend
9+
replicas: 1
10+
template:
11+
metadata:
12+
labels:
13+
app: countly-frontend
14+
spec:
15+
containers:
16+
- name: countly-frontend
17+
image: countly/frontend:19.08.1
18+
ports:
19+
- containerPort: 6001
20+
readinessProbe:
21+
httpGet:
22+
path: /ping
23+
port: 6001
24+
initialDelaySeconds: 60
25+
periodSeconds: 5
26+
env:
27+
- name: COUNTLY_PLUGINS
28+
value: "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"
29+
- name: COUNTLY_CONFIG_API_FILESTORAGE
30+
value: "gridfs"
31+
- name: COUNTLY_CONFIG_API_MONGODB
32+
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
33+
- name: COUNTLY_CONFIG_FRONTEND_MONGODB
34+
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Ingress
3+
metadata:
4+
name: countly-ingress
5+
annotations:
6+
nginx.ingress.kubernetes.io/rewrite-target: /
7+
kubernetes.io/ingress.global-static-ip-name: "countly-static-ip"
8+
spec:
9+
rules:
10+
- http:
11+
paths:
12+
- path: /i
13+
backend:
14+
serviceName: countly-api
15+
servicePort: 3001
16+
- path: /i/*
17+
backend:
18+
serviceName: countly-api
19+
servicePort: 3001
20+
- path: /o
21+
backend:
22+
serviceName: countly-api
23+
servicePort: 3001
24+
- path: /o/*
25+
backend:
26+
serviceName: countly-api
27+
servicePort: 3001
28+
- path: /*
29+
backend:
30+
serviceName: countly-frontend
31+
servicePort: 6001

bin/docker/k8s/countly-ingress.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Ingress
3+
metadata:
4+
name: countly-ingress
5+
annotations:
6+
nginx.ingress.kubernetes.io/rewrite-target: /
7+
spec:
8+
rules:
9+
- http:
10+
paths:
11+
- path: /i
12+
backend:
13+
serviceName: countly-api
14+
servicePort: 3001
15+
- path: /i/*
16+
backend:
17+
serviceName: countly-api
18+
servicePort: 3001
19+
- path: /o
20+
backend:
21+
serviceName: countly-api
22+
servicePort: 3001
23+
- path: /o/*
24+
backend:
25+
serviceName: countly-api
26+
servicePort: 3001
27+
- path: /*
28+
backend:
29+
serviceName: countly-frontend
30+
servicePort: 6001

bin/docker/k8s/gce-cluster-init.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
4+
# IGNORE IF YOU HAVE KUBERNETES SET UP ALREADY
5+
# ---------------------------------------------------------------------------------------------------
6+
# -------------------------- IGNORE IF YOU HAVE ALREADY SET UP KUBECTL ------------------------------
7+
# ---------------------------------------------------------------------------------------------------
8+
# Kubernentes setup
9+
export PROJECT_NAME=countly-playground
10+
export CLUSTER_NAME=countly
11+
export ZONE_NAME=europe-west3-b
12+
13+
14+
gcloud config set project "${PROJECT_NAME}"
15+
gcloud config set compute/zone "${ZONE_NAME}"
16+
gcloud components update
17+
gcloud container clusters get-credentials "${CLUSTER_NAME}"
18+
kubectl config set-cluster "${CLUSTER_NAME}"
19+
# ---------------------------------------------------------------------------------------------------
20+
21+
22+
23+
# ---------------------------------------------------------------------------------------------------
24+
# ---------------------------- IGNORE IF YOU HAVE ALREADY SET UP HELM -------------------------------
25+
# ---------------------------------------------------------------------------------------------------
26+
# Cluster & Helm setup
27+
# give user rights to give helm rights
28+
kubectl create clusterrolebinding user-cluster-admin-binding --clusterrole=cluster-admin --user="${GCE_USER}"
29+
kubectl create clusterrolebinding tiller-cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
30+
# give helm the rights
31+
kubectl create -f rbac-config.yaml
32+
kubectl --namespace kube-system create serviceaccount tiller
33+
helm init
34+
kubectl --namespace kube-system patch deploy tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
35+
# ---------------------------------------------------------------------------------------------------
36+
37+
38+
39+
# Create a namespace
40+
kubectl create ns countly
41+
kubectl config set-context --current --namespace=countly
42+
43+
# Install MongoDB
44+
kubectl apply -f mongo/storage-class.yaml
45+
helm install --name db -f mongo/values.yaml stable/mongodb-replicaset
46+
47+
## Wait ~ 3 minutes until all 3 replica set pods spin up
48+
kubectl get po
49+
50+
51+
# Install Countly deployments & services
52+
kubectl apply -f countly-frontend.yaml
53+
kubectl apply -f countly-frontend-service.yaml
54+
kubectl apply -f countly-api.yaml
55+
kubectl apply -f countly-api-service.yaml
56+
57+
# Install Countly ingress
58+
gcloud compute addresses create countly-static-ip --global
59+
kubectl apply -f countly-ingress-gce.yaml
60+
# Alternatively install ingress without static address created above
61+
#kubectl apply -f countly-ingress.yaml
62+
63+
## Wait ~ 3 minutes until all Countly nodes spin up
64+
kubectl get po
65+
66+
## Wait ~ 5-10 minutes until Ingress sets up and open static Countly IP address
67+
# Check Ingress status at GCE console in the meantime, then wait 10 more minutes
68+
kubectl get ing
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: StorageClass
2+
apiVersion: storage.k8s.io/v1
3+
metadata:
4+
name: mongo-storageclass
5+
provisioner: kubernetes.io/gce-pd
6+
parameters:
7+
type: pd-ssd
8+

0 commit comments

Comments
 (0)