Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 654ed51

Browse files
Merge remote-tracking branch 'CoderDojo/master' into staging
2 parents 8b03aee + 57d10ec commit 654ed51

14 files changed

+222
-125
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.git
2+
node_modules
3+
.gitignore
4+
*.md
5+
*Dockerfile
6+
*.sh
7+
!docker-entrypoint.sh
8+
deploy
9+
example
10+
*.yml

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.10.48

Dockerfile

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
FROM mhart/alpine-node:0.10
2-
MAINTAINER nearForm <[email protected]>
1+
FROM mhart/alpine-node:0.10.48
2+
MAINTAINER butlerx <[email protected]>
33

4-
RUN apk-install git make gcc g++ python postgresql-client
5-
6-
RUN mkdir -p /usr/src/app /usr/src/app/config /usr/src/app/email-templates /usr/src/app/data /usr/src/app/scripts
4+
RUN apk add --update git build-base python postgresql-client && \
5+
mkdir -p /usr/src/app
76
WORKDIR /usr/src/app
8-
9-
COPY package.json /usr/src/app/
10-
RUN npm install --production && rm -rf /root/.npm
11-
COPY config /usr/src/app/config/
12-
COPY data /usr/src/app/data/
13-
COPY scripts /usr/src/app/scripts/
14-
COPY email-templates /usr/src/app/email-templates/
15-
COPY *.js /usr/src/app/
16-
17-
RUN apk del make gcc g++ python && rm -rf /tmp/* /root/.npm /root/.node-gyp
7+
ADD . /usr/src/app/
8+
RUN npm install && \
9+
rm -rf /root/.npm && \
10+
apk del build-base python && \
11+
rm -rf /tmp/* /root/.npm /root/.node-gyp
12+
EXPOSE 10303
13+
CMD ["node", "service.js"]

circle.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ machine:
66
dependencies:
77
pre:
88
- npm -g install npm@latest-2
9-
- if [ "$CIRCLE_BRANCH" = "master" ]; then cd ~/ && git clone [email protected]:CoderDojo/cp-translations.git && cd cp-translations && ./build.sh; fi
109
override:
1110
- npm install
1211
test:

config/development.env

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
POSTGRES_HOST=localhost
2+
POSTGRES_NAME=cp-users-development
3+
POSTGRES_USERNAME=platform
4+
POSTGRES_PASSWORD=QdYx3D5y
5+
POSTGRES_PORT=5432
6+
7+
MAILTRAP_ENABLED=true
8+
MAIL_HOST=mailtrap.io
9+
MAIL_PORT=2525
10+
MAIL_USER=397746d4abc52902b
11+
MAIL_PASS=0383c445ef22d4
12+
13+
HOSTNAME=localhost
14+
15+

dev.Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM mhart/alpine-node:0.10.48
2+
MAINTAINER butlerx <[email protected]>
3+
4+
RUN apk add --update git build-base python postgresql-client && \
5+
npm install -g nodemon && \
6+
mkdir -p /usr/src/app /usr/src/cp-translations
7+
ADD docker-entrypoint.sh /usr/src
8+
EXPOSE 10303
9+
VOLUME /usr/src/app /usr/src/cp-translations
10+
CMD ["/usr/src/docker-entrypoint.sh"]

docker-entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /usr/bin/env sh
2+
cd /usr/src/cp-translations || exit
3+
npm link
4+
cd /usr/src/app || exit
5+
npm install && npm link cp-translations
6+
nodemon service.js
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var async = require('async');
2+
/**
3+
* Resave sys_user structure for those affected by https://github.com/CoderDojo/community-platform/issues/1202
4+
*/
5+
module.exports = function (args, done) {
6+
var seneca = this;
7+
var plugin = args.role;
8+
var entity = seneca.make$('sys_user');
9+
entity.native$(function (err, client, release) {
10+
var finishUp = function (err) {
11+
release();
12+
done(err);
13+
};
14+
if (err) finishUp(err);
15+
client.query('SELECT p.id, u.id as userId FROM cd_profiles p JOIN sys_user u on u.id = p.user_id WHERE u.name != p.name;',
16+
function (err, res) {
17+
if (err) finishUp(err);
18+
async.each(res.rows, function (faulty, eCb) {
19+
async.waterfall([
20+
// Recover originalProfile
21+
function (wfCb) {
22+
seneca.act({role: plugin, cmd: 'load', id: faulty.id}, function (err, profile) {
23+
if (err) eCb(err);
24+
wfCb(null, profile);
25+
});
26+
},
27+
// Recover original user for perm bypass
28+
function (profile, wfCb) {
29+
// it's not a typo, camelCase is not applied through native$
30+
seneca.act({role: 'cd-users', cmd: 'load', id: faulty.userid}, function (err, user) {
31+
if (err) eCb(err);
32+
wfCb(null, profile, user);
33+
});
34+
},
35+
// re-Save profiles
36+
function (profile, user, wfCb) {
37+
if (['attendee-o13', 'attendee-u13'].indexOf(profile.userType) > -1) {
38+
seneca.act({role: plugin, cmd: 'update-youth-profile', profile: profile, user: user}, wfCb);
39+
} else {
40+
seneca.act({role: plugin, cmd: 'create', profile: profile, user: user}, wfCb);
41+
}
42+
}
43+
], eCb);
44+
}, finishUp);
45+
});
46+
});
47+
};

network.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
module.exports = function (seneca) {
44
seneca.listen()
5-
.client({type: 'web', port: 10304, pin: {role: 'cd-salesforce', cmd: '*'}})
6-
.client({type: 'web', port: 10301, pin: {role: 'cd-dojos', cmd: '*'}})
7-
.client({type: 'web', port: 10305, pin: {role: 'cd-badges', cmd: '*'}});
5+
.client({
6+
type: 'web',
7+
host: process.env.CD_DOJOS || 'localhost',
8+
port: 10301,
9+
pin: {
10+
role: 'cd-dojos',
11+
cmd: '*'
12+
}
13+
})
14+
.client({
15+
type: 'web',
16+
host: process.env.CD_BADGES || 'localhost',
17+
port: 10305,
18+
pin: {
19+
role: 'cd-badges',
20+
cmd: '*'
21+
}
22+
});
823
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"scripts": {
1010
"test": "npm run lint && bash -c 'source ./config/development.env; ./node_modules/.bin/lab --ignore __core-js_shared__ --flat --threshold 50 -r html -o ./coverage/coverage.html -r lcov -o ./coverage/lcov.info -r json -o ./coverage/coverage.json -r lab-quieter-reporter -o stdout -m 5000'",
11+
"testdata": "node test/lib/service.js",
1112
"covrep": "bash test/covrep.sh",
1213
"lint": "./node_modules/.bin/semistandard *.js config/config.js"
1314
},

0 commit comments

Comments
 (0)