-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
164 lines (145 loc) · 4.23 KB
/
gulpfile.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
"use strict";
/**
* Running single docker container rebuild
* https://staxmanade.com/2016/09/how-to-update-a-single-running-docker-compose-container/
*
* docker-compose up -d --no-deps --build <service_name>
*/
const path = require("path");
let webFrontEnd = path.resolve(__dirname, "services", "web-front-end");
let dockerCompose = path.resolve(__dirname, "cluster-setup", "osprey-odn");
// grab our gulp packages
let gulp = require("gulp");
let exec = require("gulp-exec");
let usage = require("gulp-help-doc");
let options = {
continueOnError: false, // default = false, true means don't emit error event
pipeStdout: false, // default = false, true means stdout is written to file.contents
customTemplatingThing: "test" // content passed to gutil.template()
};
let reportOptions = {
err: true, // default = true, false means don't write err
stderr: true, // default = true, false means don't write stderr
stdout: true // default = true, false means don't write stdout
};
/**
* This simply defines help task which would produce usage
* display for this gulpfile. Simple run `gulp help` to see how it works.
* NOTE: this task will not appear in a usage output as far as it is not
* marked with the @task tag.
*/
gulp.task("help", function() {
return usage(gulp);
});
/**
* We may also link usage as default gulp task:
*/
gulp.task("default", ["help"]);
/**
* Re-WebPack the script files
* @task {webpack}
*/
gulp.task("webpack", () => {
gulp
.src(webFrontEnd)
.pipe(
exec("npm run --prefix <%= file.path %> build:dev"),
options
)
.pipe(exec.reporter(reportOptions));
});
// help function to just rebuild the one container
function rebuildOne(service) {
// docker-compose up -d --no-deps --build <service_name>
let composerFile = path.join(dockerCompose, "/docker-compose.yml");
let options = { service };
return gulp
.src(composerFile)
.pipe(
exec(
"docker-compose -f <%= file.path %> up -d --no-deps --build <%= options.service %>",
options
)
)
.pipe(exec.reporter(reportOptions));
}
/**
* Rebuild the file-mgt docker container
* @task {file-mgt{}
*/
gulp.task("file-mgt", () => {
return rebuildOne("filemgt");
});
/**
* Rebuild the front end docker container (inc webpack)
* @task {web-front-end}
*/
gulp.task("web-front-end", ["webpack"], () => {
return rebuildOne("data-layer");
});
/**
* @task {data-layer} Rebuild the data-layer docker container
*/
gulp.task("data-layer", () => {
return rebuildOne("data-layer");
});
/**
* Issue the docker-compose up command
* @task {compose-up}
*/
gulp.task("compose-up", () => {
let composerFile = path.join(dockerCompose, "/docker-compose.yml");
return gulp
.src(composerFile)
.pipe(exec("docker-compose -f <%= file.path %> up -d", options))
.pipe(exec.reporter(reportOptions));
});
/**
* Setup the database post compose-up
*/
gulp.task("setup", () => {
let composerFile = path.join(dockerCompose, "/setup.sh");
return gulp
.src(composerFile)
.pipe(exec(" <%= file.path %>", options))
.pipe(exec.reporter(reportOptions));
});
/**
* Issue the docker-compose down command
* @task {compose-down}
*/
gulp.task("compose-down", () => {
let composerFile = path.join(dockerCompose, "/docker-compose.yml");
return gulp
.src(composerFile)
.pipe(exec("docker-compose -f <%= file.path %> down", options))
.pipe(exec.reporter(reportOptions));
});
/**
* Issue the docker-compose build command
* @task {compose-build}
*/
gulp.task("compose-build", () => {
let composerFile = path.join(dockerCompose, "/docker-compose.yml");
return gulp
.src(composerFile)
.pipe(exec("docker-compose -f <%= file.path %> build", options))
.pipe(exec.reporter(reportOptions));
});
/**
* @task {docker-monitor} Run the docker monitor script
*/
gulp.task("docker-monitor", () => {
let script = path.join(dockerCompose, "/monitor.sh");
return gulp
.src(script)
.pipe(exec("<%= file.path %>", options))
.pipe(exec.reporter(reportOptions));
});
// gulp.task('watch', function() {
// gulp.watch('./**/*', ['copyAlpha']);
// });
// gulp.task('copyAlpha', function() {
// // copy any html files in source/ to public/
// gulp.src('./**/*').pipe(gulp.dest('w:/quiz'));
// });