-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (57 loc) · 1.9 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
"use strict"
const chmod = require("gulp-chmod");
const del = require("del");
const gulp = require("gulp");
const lambda = require("gulp-awslambda");
const shell = require('gulp-shell')
const zip = require("gulp-zip");
const dest = {
lambda: "dist"
};
const paths = {
src: [
"worker.py",
"config.py",
"deploy-worker"
]
};
gulp.task("clean", function () {
return del([ dest.lambda ]);
});
gulp.task("lambda.cert", function() {
return gulp.src(`${process.env.HOME}/.machine/{ca,key,cert}.pem`).
pipe(chmod(644)).
pipe(gulp.dest(`${dest.lambda}/cert`));
});
gulp.task("lambda.vendor.docker", function() {
return gulp.src("/usr/local/bin/docker").
pipe(gulp.dest(`${dest.lambda}/vendor`));
});
gulp.task("lambda.vendor.awscli", function() {
return gulp.src("vendor/aws").
pipe(gulp.dest(`${dest.lambda}/vendor`));
});
gulp.task("lambda.vendor.compose", function() {
return gulp.src("vendor/docker-compose").
pipe(gulp.dest(`${dest.lambda}/vendor`));
});
gulp.task("lambda.vendor", [ "lambda.vendor.docker", "lambda.vendor.awscli", "lambda.vendor.compose" ]);
gulp.task("lambda.py.src", function () {
return gulp.src(paths.src).
pipe(gulp.dest(dest.lambda));
});
gulp.task("lambda.py", [ "lambda.py.src" ], shell.task([
`cd ${dest.lambda} && pip install -r ../requirements.txt -t .`
]));
gulp.task("lambda", [ "lambda.cert", "lambda.vendor", "lambda.py" ], function() {
gulp.src([ `${dest.lambda}/**/*`, `!${dest.lambda}/app.zip` ], { dot: true }).
pipe(zip("app.zip")).
pipe(gulp.dest(dest.lambda));
});
gulp.task("default", [ "lambda" ]);
gulp.task("deploy", [ "lambda" ], function () {
let FunctionName = "lambda-deploy-worker";
gulp.src([ `${dest.lambda}/**/*`, `!${dest.lambda}/app.zip` ]).
pipe(zip("app.zip")).
pipe(lambda(FunctionName, { region: "ap-northeast-1" }));
});