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

Commit f3ccec3

Browse files
butlerxWardormeur
authored andcommitted
Update/docker second try (#264)
* update dockerfile
1 parent d4a1422 commit f3ccec3

File tree

8 files changed

+152
-113
lines changed

8 files changed

+152
-113
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
node_modules
3+
.gitignore
4+
*.md
5+
Dockerfile
6+
*.sh
7+
deploy
8+
example
9+
*.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"]

config/development.env

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

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
},

test/lib/insert-test-users.js

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -3,102 +3,102 @@
33
var _ = require('lodash');
44
var async = require('async');
55

6-
module.exports = function () {
6+
module.exports = function () {
77

8-
var seneca = this;
8+
var seneca = this;
99

10-
var plugin = 'test-user-data';
10+
var plugin = 'test-user-data';
1111

12-
seneca.add({role: plugin, cmd: 'insert', entity: 'user'}, function (args, done) {
12+
seneca.add({role: plugin, cmd: 'insert', entity: 'user'}, function (args, done) {
1313

14-
async.waterfall([
15-
createIndependants,
16-
createDependantsChildren
17-
], function (err, users) {
18-
return done(null);
19-
});
14+
async.waterfall([
15+
createIndependants,
16+
createDependantsChildren
17+
], function (err, users) {
18+
return done(null);
19+
});
2020

21-
function createIndependants (wfCb) {
22-
var users = require('../fixtures/e2e/users.json');
23-
async.eachSeries(users, function (user, cb) {
24-
seneca.act(user, {role: 'cd-users', cmd: 'register'}, function (err, response) {
25-
if (err) return done(err);
26-
if (response.ok === false) {
27-
console.error('insert failed: ', response);
28-
return cb(response);
29-
}
30-
return cb(err, response);
31-
});
32-
}, wfCb);
33-
}
34-
35-
function createDependantsChildren (wfCb) {
36-
var children = require('../fixtures/e2e/children.json');
37-
async.eachSeries(children, function (child, cb) {
38-
function getParent (wfCb) {
39-
seneca.act({role: 'cd-users', cmd: 'list', query: {email: child.parentEmail}}, function (err, parents) {
40-
if (err) return done(err);
41-
return wfCb(null, parents[0]);
42-
});
43-
}
44-
45-
function saveChild (parent, wfCb) {
46-
child.parents = [parent.userId];
47-
seneca.act({role: 'cd-profiles', cmd: 'save-youth-profile', profile: child.data, user: parent}, function (err, savedChild) {
48-
if (err) return wfCb(err);
49-
if (savedChild.ok === false) {
50-
console.error('insert failed: ', savedChild);
51-
return wfCb(savedChild);
52-
}
53-
return wfCb(err, savedChild);
54-
});
55-
}
56-
57-
async.waterfall([
58-
getParent,
59-
saveChild
60-
], cb);
61-
62-
}, function (err, data) {
63-
return wfCb();
64-
});
65-
66-
}
67-
68-
});
69-
70-
seneca.add({role: plugin, cmd: 'insert', entity: 'agreement'}, function (args, done) {
71-
var users = require('../fixtures/e2e/users.json');
72-
var champs = _.filter(users, function (user) {
73-
return user.user.email.indexOf('champion') > -1;
74-
});
75-
async.eachSeries(champs, function (champ, sCb) {
76-
async.waterfall([
77-
getUser,
78-
saveAgreement
79-
], sCb);
80-
81-
function getUser (wfCb) {
82-
seneca.act({role: 'cd-users', cmd: 'list', query: {email: champ.user.email}}, function (err, champs) {
21+
function createIndependants (wfCb) {
22+
var users = require('../fixtures/e2e/users.json');
23+
async.eachSeries(users, function (user, cb) {
24+
seneca.act(user, {role: 'cd-users', cmd: 'register'}, function (err, response) {
8325
if (err) return done(err);
84-
return wfCb(null, champs[0]);
26+
if (response.ok === false) {
27+
console.error('insert failed: ', response);
28+
return cb(response);
29+
}
30+
return cb(err, response);
8531
});
86-
}
87-
88-
function saveAgreement (champ, wfCb) {
89-
var payload = {
90-
fullName: champ.name,
91-
userId: champ.id
92-
};
93-
seneca.act({role: 'cd-agreements', cmd: 'save', agreement: payload}, function (err, agreement) {
32+
}, wfCb);
33+
}
34+
35+
function createDependantsChildren (wfCb) {
36+
var children = require('../fixtures/e2e/children.json');
37+
async.eachSeries(children, function (child, cb) {
38+
function getParent (wfCb) {
39+
seneca.act({role: 'cd-users', cmd: 'list', query: {email: child.parentEmail}}, function (err, parents) {
9440
if (err) return done(err);
95-
return wfCb(null, agreement);
96-
});
97-
}
98-
}, done);
99-
});
100-
101-
return {
102-
name: plugin
103-
};
104-
};
41+
return wfCb(null, parents[0]);
42+
});
43+
}
44+
45+
function saveChild (parent, wfCb) {
46+
child.parents = [parent.userId];
47+
seneca.act({role: 'cd-profiles', cmd: 'save-youth-profile', profile: child.data, user: parent}, function (err, savedChild) {
48+
if (err) return wfCb(err);
49+
if (savedChild.ok === false) {
50+
console.error('insert failed: ', savedChild);
51+
return wfCb(savedChild);
52+
}
53+
return wfCb(err, savedChild);
54+
});
55+
}
56+
57+
async.waterfall([
58+
getParent,
59+
saveChild
60+
], cb);
61+
62+
}, function (err, data) {
63+
return wfCb();
64+
});
65+
66+
}
67+
68+
});
69+
70+
seneca.add({role: plugin, cmd: 'insert', entity: 'agreement'}, function (args, done) {
71+
var users = require('../fixtures/e2e/users.json');
72+
var champs = _.filter(users, function (user) {
73+
return user.user.email.indexOf('champion') > -1;
74+
});
75+
async.eachSeries(champs, function (champ, sCb) {
76+
async.waterfall([
77+
getUser,
78+
saveAgreement
79+
], sCb);
80+
81+
function getUser (wfCb) {
82+
seneca.act({role: 'cd-users', cmd: 'list', query: {email: champ.user.email}}, function (err, champs) {
83+
if (err) return done(err);
84+
return wfCb(null, champs[0]);
85+
});
86+
}
87+
88+
function saveAgreement (champ, wfCb) {
89+
var payload = {
90+
fullName: champ.name,
91+
userId: champ.id
92+
};
93+
seneca.act({role: 'cd-agreements', cmd: 'save', agreement: payload}, function (err, agreement) {
94+
if (err) return done(err);
95+
return wfCb(null, agreement);
96+
});
97+
}
98+
}, done);
99+
});
100+
101+
return {
102+
name: plugin
103+
};
104+
};

test/lib/service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ seneca.ready(function() {
2323

2424
require('../../network.js')(seneca);
2525
// Add "its" µs as a dependency
26-
seneca.client({ type: 'web', port: 10303, pin: { role: 'cd-profiles', cmd: '*' } })
27-
.client({ type: 'web', port: 10303, pin: { role: 'cd-agreements', cmd: '*' } })
28-
.client({ type: 'web', port: 10303, pin: { role: 'user', cmd: '*' } })
29-
.client({ type: 'web', port: 10303, pin: { role: 'cd-users', cmd: '*' } });
26+
seneca.client({type: 'web', host: process.env.CD_USERS || 'localhost', port: 10303, pin: {role: 'cd-profiles', cmd: '*'}})
27+
.client({type: 'web', host: process.env.CD_USERS || 'localhost', port: 10303, pin: {role: 'cd-agreements', cmd: '*'}})
28+
.client({ type: 'web', host: process.env.CD_USERS || 'localhost', port: 10303, pin: {role: 'user', cmd: '*'}})
29+
.client({type: 'web', host: process.env.CD_USERS || 'localhost', port: 10303, pin: {role: 'cd-users', cmd: '*'}})

0 commit comments

Comments
 (0)