Skip to content

Commit 497fe13

Browse files
committed
Merge branch 'master' into next
2 parents cd0e2ed + 0633478 commit 497fe13

Some content is hidden

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

43 files changed

+858
-378
lines changed

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## Version 18.08.1
2+
3+
**Fixes**
4+
5+
* [assistant] fixed browser side error with a empty server
6+
* [config] switch buttons resized
7+
* [core] fixed bug when admin can't edit apps in some cases
8+
* [docker] added countly-core docker image without mongodb
9+
* [docker] improved environment variable based configuration
10+
* [enterprise] make sure drill library loads before cohorts and funnels
11+
* [events] fixed padding on selectize items(omit segment)
12+
* [jsdoc] updated doc template
13+
* [plugins] use POST app config update instead of GET
14+
* [push] UI fixes
15+
* [push] fixed for p12 credentials upload resulting in unknown error
16+
* [push] improved geolocations support
17+
* [sdk] install udpated version of web sdk
18+
* [upgrade] improved checks in mongodb upgrade scripts
19+
120
## Version 18.08
221

322
**Fixes**

Dockerfile-core

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM phusion/baseimage:0.9.16
2+
3+
CMD ["/sbin/my_init"]
4+
5+
## Setup Countly
6+
ENV INSIDE_DOCKER 1
7+
ENV INSIDE_DOCKER_NOMONGO 1
8+
9+
COPY / /opt/countly
10+
RUN useradd -r -M -U -d /opt/countly -s /bin/false countly && \
11+
echo "countly ALL=(ALL) NOPASSWD: /usr/bin/sv restart countly-api countly-dashboard" >> /etc/sudoers.d/countly && \
12+
/opt/countly/bin/countly.install.sh
13+
14+
# Change MongoDB folder permissions and add services folders
15+
RUN mkdir /etc/service/nginx && \
16+
mkdir /etc/service/countly-api && \
17+
mkdir /etc/service/countly-dashboard && \
18+
echo "" >> /etc/nginx/nginx.conf && \
19+
echo "daemon off;" >> /etc/nginx/nginx.conf
20+
21+
# Add services' run scripts
22+
ADD ./bin/commands/docker/nginx.sh /etc/service/nginx/run
23+
ADD ./bin/commands/docker/countly-api.sh /etc/service/countly-api/run
24+
ADD ./bin/commands/docker/countly-dashboard.sh /etc/service/countly-dashboard/run
25+
26+
# Only root can change run scripts
27+
RUN chown root /etc/service/nginx/run && \
28+
chown -R countly:countly /opt/countly
29+
30+
EXPOSE 80
31+
32+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Gruntfile.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ module.exports = function(grunt) {
222222
plugins.push('push_approver');
223223
}
224224
}
225+
226+
if (plugins.indexOf('drill') !== -1) {
227+
if (plugins.indexOf('cohorts') !== -1) {
228+
plugins.splice(plugins.indexOf('cohorts'), 1);
229+
plugins.push('cohorts');
230+
}
231+
if (plugins.indexOf('funnels') !== -1) {
232+
plugins.splice(plugins.indexOf('funnels'), 1);
233+
plugins.push('funnels');
234+
}
235+
}
225236

226237
plugins.forEach(function(plugin){
227238
var files, pluginPath = path.join(__dirname, 'plugins', plugin),
@@ -345,4 +356,4 @@ module.exports = function(grunt) {
345356

346357
grunt.registerTask('dist-all', ['dist', 'plugins', 'locales']);
347358

348-
};
359+
};

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Plus lots of [open source libraries](http://resources.count.ly/docs/list-of-open
5353

5454
## Security
5555

56-
We take security very seriously at Countly. Community Edition code is 100% open source and peer reviewed, to ensure nobody's Countly instance is ever compromised or hacked. If you wish to report a security issue, please email [email protected]
56+
Security is very important to us. If you discover any issue regarding security, please disclose the information responsibly by sending an email to [email protected] and **not by creating a GitHub issue**.
5757

5858
## What makes Countly unique?
5959

api/config.sample.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ var countlyConfig = {
131131
// Set your host IP or domain to be used in the emails sent
132132
// countlyConfig.host = "YOUR_IP_OR_DOMAIN";
133133

134-
module.exports = require('./configextender')(countlyConfig);
134+
module.exports = require('./configextender')('API', countlyConfig, process.env);

api/configextender.js

+108-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var traverse = require('traverse');
2-
31
var parser = function(val) {
42
var parsedVal;
53
try {
@@ -10,56 +8,129 @@ var parser = function(val) {
108
val = parsedVal;
119
} else if (Array.isArray(parsedVal)) {
1210
val = parsedVal;
11+
} else if (typeof parsedVal === 'object') {
12+
val = parsedVal;
1313
}
1414
} catch (error) {}
1515
return val;
1616
};
1717

18-
var read = function(config, parser){
19-
var tc = traverse(config);
20-
var tcKeyMap = {};
18+
const OVERRIDES = {
19+
MONGODB: {
20+
REPLSETSERVERS: 'replSetServers',
21+
REPLICANAME: 'replicaName',
22+
MAX_POOL_SIZE: 'max_pool_size',
23+
DBOPTIONS: 'dbOptions',
24+
SERVEROPTIONS: 'serverOptions'
25+
},
2126

22-
// make paths case-insensitive. Useful while converting from uppercase env
23-
// vars to camelCase variables.
24-
tc.paths().forEach(function(path) {
25-
// store paths as lowercase with their corresponding actual paths. will be
26-
// used while updating the value
27-
tcKeyMap[path.join('_').toLowerCase()] = path;
28-
});
27+
API: {
28+
MAX_SOCKETS: 'max_sockets',
29+
},
30+
31+
WEB: {
32+
USE_INTERCOM: 'use_intercom',
33+
SECURE_COOKIES: 'secure_cookies'
34+
},
35+
36+
IGNOREPROXIES: 'ignoreProxies',
37+
FILESTORAGE: 'fileStorage',
38+
RELOADCONFIGAFTER: 'reloadConfigAfter'
39+
};
40+
41+
/**
42+
* Digs one level down in config document
43+
*
44+
* @param {[type]} config [description]
45+
* @param {[type]} over [description]
46+
* @param {[type]} name [description]
47+
* @param {[type]} value [description]
48+
* @return {[type]} [description]
49+
*/
50+
function dig (config, over, name, value) {
51+
let comps = name.split('_');
52+
53+
for (let i = comps.length; i > 0; i--) {
54+
let n = comps.slice(0, i).join('_');
55+
56+
if (n in over) {
57+
let sub;
58+
59+
if (typeof over[n] === 'string') {
60+
sub = over[n];
61+
over[n] = {};
62+
} else {
63+
sub = Object.keys(config).filter(k => k.toUpperCase() === n)[0];
64+
}
2965

30-
var ref = process.env;
31-
var env;
32-
for (env in ref) {
33-
var val = ref[env];
66+
name = comps.slice(i).join('_');
3467

35-
// we only care about env vars starting with "countly"
36-
if (!env.startsWith('COUNTLY_')) {
37-
continue;
68+
if (!name || comps.length === 1) {
69+
config[sub] = value;
70+
return true;
71+
}
72+
73+
if (typeof config[sub] === 'object') {
74+
return dig(config[sub], over[n], name, value);
75+
} else if (sub) {
76+
config[sub] = {};
77+
return dig(config[sub], over[n], name, value);
78+
} else {
79+
config[n] = {};
80+
return dig(config[n], over[n], name, value);
81+
}
82+
} else if (n === over) {
83+
name = over;
84+
config[name] = value;
85+
return true;
3886
}
39-
var path = env.split('_');
40-
if (path.length < 2) {
41-
continue;
87+
}
88+
89+
for (let i = 1; i <= comps.length; i++) {
90+
let n = comps.slice(0, i).join('_'),
91+
sub = Object.keys(config).filter(k => k.toUpperCase() === n)[0],
92+
name = comps.slice(i).join('_');
93+
94+
if (sub) {
95+
if (comps.length === 1) {
96+
config[sub] = value;
97+
return true;
98+
} else {
99+
config[sub] = typeof config[sub] === 'object' ? config[sub] : {};
100+
return dig(config[sub], {}, name, value);
101+
}
42102
}
103+
}
43104

44-
// get the underlying value of env var
45-
val = parser(val);
46-
if (!val) {
47-
continue;
105+
comps.forEach((c, i) => {
106+
if (i === comps.length - 1) {
107+
config[c.toLowerCase()] = value;
108+
} else {
109+
config = config[c.toLowerCase()] = {};
48110
}
111+
})
49112

50-
// generate path from env vars, while removing the first COUNTLY_ part
51-
var newPath = path.slice(1).map(function(node) {
52-
return parser(node.toLowerCase());
53-
});
113+
return true;
114+
}
54115

55-
// if we dont have the new path defined in config, we might be creating a
56-
// new node
57-
var location = tcKeyMap[newPath.join('_')] || newPath;
58-
tc.set(location, val);
116+
module.exports = function (mode, config, opts) {
117+
// back compatibility
118+
if (typeof mode === 'object') {
119+
config = mode;
120+
mode = 'API';
121+
opts = process.env;
59122
}
60-
};
123+
124+
if (['API', 'FRONTEND'].indexOf(mode) === -1) {
125+
throw new Error('Invalid config mode ' + mode);
126+
}
127+
128+
config = JSON.parse(JSON.stringify(config));
129+
130+
Object.keys(opts).filter(n => n.indexOf(`COUNTLY_CONFIG_${mode}_`) === 0).forEach(n => {
131+
let comps = n.split('_').slice(3);
132+
dig(config, OVERRIDES, comps.join('_'), parser(opts[n]));
133+
});
61134

62-
module.exports = function (config) {
63-
read(config, parser);
64135
return config;
65136
};

bin/commands/docker/countly-api.sh

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

3-
until mongo localhost --eval "db.stats()" | grep "collections"
4-
do
5-
echo
6-
echo "[api] waiting for MongoDB to allocate files ..."
7-
sleep 1
8-
done
9-
sleep 3
10-
echo "[api] MongoDB started"
3+
if [ "$INSIDE_DOCKER_NOMONGO" != "1" ]
4+
then
5+
until mongo localhost --eval "db.stats()" | grep "collections"
6+
do
7+
echo
8+
echo "[api] waiting for MongoDB to allocate files ..."
9+
sleep 1
10+
done
11+
sleep 3
12+
echo "[api] MongoDB started"
13+
fi
1114

1215
exec /sbin/setuser countly /usr/bin/nodejs /opt/countly/api/api.js
+11-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env bash
22

3-
until mongo localhost --eval "db.stats()" | grep "collections"
4-
do
5-
echo
6-
echo "[dashboard] waiting for MongoDB to allocate files ..."
7-
sleep 1
8-
done
9-
sleep 3
10-
echo "[dashboard] MongoDB started"
3+
if [ "$INSIDE_DOCKER_NOMONGO" != "1" ]
4+
then
5+
until mongo localhost --eval "db.stats()" | grep "collections"
6+
do
7+
echo
8+
echo "[dashboard] waiting for MongoDB to allocate files ..."
9+
sleep 1
10+
done
11+
sleep 3
12+
echo "[dashboard] MongoDB started"
13+
fi
1114

1215
exec /sbin/setuser countly /usr/bin/nodejs /opt/countly/frontend/express/app.js

bin/countly.install.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
totalm=$(free -m | awk '/^Mem:/{print $2}')
3-
if [ "$totalm" -lt "2000" ]; then
3+
if [ "$totalm" -lt "1800" ]; then
44
echo "Countly requires at least 2Gb of RAM"
55
exit 1
66
fi
@@ -12,4 +12,4 @@ elif [ -f /etc/lsb-release ]; then
1212
bash $DIR/countly.install_ubuntu.sh 2>&1 | tee $DIR/../log/countly-install-$DATE.log
1313
elif [ -f /etc/redhat-release ]; then
1414
bash $DIR/countly.install_rhel.sh 2>&1 | tee $DIR/../log/countly-install-$DATE.log
15-
fi
15+
fi

bin/countly.install_ubuntu.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,16 @@ apt-get -y install sendmail
6969
( cd $DIR/.. ; npm install -g grunt-cli --unsafe-perm ; npm install --unsafe-perm)
7070

7171
#install mongodb
72-
bash $DIR/scripts/mongodb.install.sh
72+
if [ "$INSIDE_DOCKER_NOMONGO" != "1" ]
73+
then
74+
bash $DIR/scripts/mongodb.install.sh
75+
fi
7376

7477
#configure and start nginx
7578
cp /etc/nginx/sites-enabled/default $DIR/config/nginx.default.backup
7679
cp $DIR/config/nginx.server.conf /etc/nginx/sites-enabled/default
7780
cp $DIR/config/nginx.conf /etc/nginx/nginx.conf
81+
7882
if [ "$INSIDE_DOCKER" != "1" ]
7983
then
8084
/etc/init.d/nginx restart
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
If server runs mongodb 3.4, you can upgrade directly to mongo 3.6
22
If not, you need to first upgrade to mongo 3.4 and only then to mongo3.6
33

4-
After upgrading check if everything is working and only then witch to feature compatability version
4+
After upgrading check if everything is working and only then witch to feature compatability version
5+
6+
If you want to automate this process, you can run upgrade.mongo.sh directly to do version checks and upgrade to MongoDB 3.6

0 commit comments

Comments
 (0)