-
Notifications
You must be signed in to change notification settings - Fork 2
/
shipitfile.js
70 lines (61 loc) · 1.78 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
/* eslint-disable import/no-extraneous-dependencies */
const deploy = require('shipit-deploy')
const shared = require('shipit-shared')
/**
* @param {Shipit} shipit
*/
module.exports = shipit => {
deploy(shipit)
shared(shipit)
shipit.initConfig({
default: {
deployTo: '/home/deploy/markets-server',
keepReleases: 5,
repositoryUrl: 'https://github.com/horizontalsystems/markets-server.git',
shared: {
overwrite: true,
files: ['.env', '.bq-key.json'],
dirs: ['node_modules', 'docs']
}
},
prod_api: {
branch: 'master',
servers: ['[email protected]'],
},
prod_syncer: {
branch: 'master',
servers: ['[email protected]'],
},
prod_syncer2: {
branch: 'master',
servers: ['[email protected]'],
},
dev_api: {
branch: 'develop',
servers: ['[email protected]'],
deployTo: '/home/ubuntu/markets-server',
}
})
const remote = cmd => {
shipit.remote(`cd ${shipit.config.deployTo}/current && ${cmd}`)
}
shipit.on('deployed', () => shipit.start('npm:install'))
shipit.on('rollback', () => shipit.start('npm:install'))
shipit.blTask('npm:install', async () => {
remote('npm install --production')
})
shipit.blTask('copy-env', () => {
shipit.copyToRemote('.env.prod', `${shipit.config.deployTo}/shared/.env`)
})
shipit.blTask('setup:node', async () => {
// enable interactive mode in .bashrc
// # case $- in
// # *i*) ;;
// # *) return;;
// # esac
await shipit.remote('curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash')
await shipit.remote('nvm install --lts')
await shipit.remote('nvm install-latest-npm')
await shipit.remote('npm install pm2 -g')
})
}