-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathshipitfile.js
75 lines (64 loc) · 2.09 KB
/
shipitfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// the deploy config
module.exports = function config(shipit) {
require('shipit-deploy')(shipit);
require('shipit-shared-copy')(shipit);
shipit.initConfig({
default: {
workspace: '/tmp/app-koa2boilerplate',
dirToCopy: '/tmp/app-koa2boilerplate/dist',
deployTo: '/data/repos/app-koa2bp',
repositoryUrl: '[email protected]:lanvige/koa2-boilerplate.git',
branch: 'master',
ignores: ['.DS_Store', '.git', 'node_modules'],
rsync: ['--del'],
keepReleases: 2,
shallowClone: false,
shared: {
overwrite: true,
files: [
'config/application.json',
'config/database.json',
],
},
},
staging: {
servers: '[email protected]',
},
prod: {
servers: '[email protected]',
},
});
shipit.task('pwd', () => shipit.remote('pwd'));
// npm install & build
shipit.blTask('yarn-install', () => {
shipit.log('yarn install.');
return shipit.local('yarn install', { cwd: '/tmp/app-koa2boilerplate' });
});
shipit.blTask('yarn-build', () => {
shipit.log('yarn build start.');
return shipit.local('yarn run build', { cwd: '/tmp/app-koa2boilerplate' });
});
shipit.on('fetched', () => {
shipit.log('run yarn build');
shipit.start(['yarn-install', 'yarn-build']);
});
// Docker dislike soft link
// So make a physical copy (deploy) instead of softlink (current)
shipit.blTask('deploy-clean', () => {
shipit.log(`cp -R ${shipit.releasePath} ${shipit.config.deployTo}/deploy`);
return shipit.remote(`rm -rf ${shipit.config.deployTo}/deploy`);
});
shipit.blTask('deploy-duplicate', () => {
shipit.log('====');
return shipit.remote(`cp -R ${shipit.releasePath} ${shipit.config.deployTo}/deploy`);
});
shipit.on('published', () => {
shipit.log('====');
return shipit.start(['deploy-clean', 'deploy-duplicate']);
});
// Docker build & run on Remote
shipit.blTask('docker-up', () => {
shipit.log('docker-compose up with build...');
return shipit.remote(`cd ${shipit.config.deployTo}/deploy; docker-compose up -d --build`);
});
};