Skip to content

Commit ab99779

Browse files
authored
Merge pull request #16 from sambaiz/serverless
support Serverless Framework
2 parents 52351d0 + 59a2744 commit ab99779

File tree

5 files changed

+76
-31
lines changed

5 files changed

+76
-31
lines changed

.gitignore

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ local-chromium.tar.gz
55

66
### https://raw.github.com/github/gitignore/49d13cdba39774f7fa224ef13f4a1153200e2710/Global/macOS.gitignore
77

8-
*.DS_Store
9-
.AppleDouble
10-
.LSOverride
11-
12-
# Icon must end with two \r
13-
Icon
14-
15-
16-
# Thumbnails
17-
._*
18-
19-
# Files that might appear in the root of a volume
20-
.DocumentRevisions-V100
21-
.fseventsd
22-
.Spotlight-V100
23-
.TemporaryItems
24-
.Trashes
25-
.VolumeIcon.icns
26-
.com.apple.timemachine.donotpresent
27-
28-
# Directories potentially created on remote AFP share
29-
.AppleDB
30-
.AppleDesktop
31-
Network Trash Folder
32-
Temporary Items
33-
.apdisk
8+
*.DS_Store
9+
.AppleDouble
10+
.LSOverride
11+
12+
# Icon must end with two \r
13+
Icon
14+
15+
16+
# Thumbnails
17+
._*
18+
19+
# Files that might appear in the root of a volume
20+
.DocumentRevisions-V100
21+
.fseventsd
22+
.Spotlight-V100
23+
.TemporaryItems
24+
.Trashes
25+
.VolumeIcon.icns
26+
.com.apple.timemachine.donotpresent
27+
28+
# Directories potentially created on remote AFP share
29+
.AppleDB
30+
.AppleDesktop
31+
Network Trash Folder
32+
Temporary Items
33+
.apdisk
3434

3535

3636
### https://raw.github.com/github/gitignore/49d13cdba39774f7fa224ef13f4a1153200e2710/Node.gitignore
@@ -83,5 +83,5 @@ jspm_packages
8383
# Yarn Integrity file
8484
.yarn-integrity
8585

86-
87-
86+
# serverless
87+
.serverless

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
22

33
Starter Kit for running Headless-Chrome by [Puppeteer](https://github.com/GoogleChrome/puppeteer) on AWS Lambda.
44

5+
It can use alone and also supported [Serverless Framework](https://github.com/serverless/serverless).
6+
7+
## Download
8+
9+
### Use alone
10+
11+
This is simple and don't need IAM role but you have to deploy package by yourself. Don't worry, even if you will become to use Serverless in the future, what you should do for migration is little.
12+
513
```
614
$ git clone -o starter-kit https://github.com/sambaiz/puppeteer-lambda-starter-kit.git your_project_name
715
```
816

17+
### Use with Serverless Framework
18+
19+
Serverless Framework can manage settings with CloudFormation and deploy.
20+
21+
```
22+
$ serverless install --url https://github.com/sambaiz/puppeteer-lambda-starter-kit --name your_project_name
23+
```
24+
925
## Run on local
1026

1127
By executing `SLOWMO_MS=250 npm run local`, you can check the operation while actually viewing the chrome (non-headless, slowmo).
@@ -16,12 +32,14 @@ Lambda's memory needs to be set to at least 384 MB, but the more memory, the bet
1632

1733
```
1834
512MB -> goto(youtube): 6.481s
19-
1536MB(Max) -> goto(youtube): 2.154s
35+
1536MB -> goto(youtube): 2.154s
2036
```
2137

2238
### chrome in package (recommended)
2339

24-
Run `npm run package`, and deploy the package.zip.
40+
If you use alone, run `npm run package`, and deploy the package.zip.
41+
42+
If you use with Serverless, run `serverless deploy` (this runs `npm run package` when packaging).
2543

2644
### chrome NOT in package
2745

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"babel-cli": "^6.26.0",
2020
"babel-preset-env": "^1.6.0",
2121
"eslint": "^4.6.1",
22-
"eslint-config-google": "^0.9.1"
22+
"eslint-config-google": "^0.9.1",
23+
"serverless-hooks-plugin": "^1.1.0"
2324
}
2425
}

serverless.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
service: puppeteer-lambda-starter-kit
2+
3+
provider:
4+
name: aws
5+
runtime: nodejs6.10
6+
memorySize: 1536
7+
timeout: 180
8+
9+
functions:
10+
test-function:
11+
handler: index.handler
12+
13+
package:
14+
artifact: ./package.zip
15+
16+
plugins:
17+
- serverless-hooks-plugin
18+
19+
custom:
20+
hooks:
21+
package:initialize:
22+
- npm run package

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,10 @@ semver@^5.3.0:
20512051
version "5.4.1"
20522052
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
20532053

2054+
serverless-hooks-plugin@^1.1.0:
2055+
version "1.1.0"
2056+
resolved "https://registry.yarnpkg.com/serverless-hooks-plugin/-/serverless-hooks-plugin-1.1.0.tgz#50bea148685b11096cee7a087cddcb49dfa8ef99"
2057+
20542058
set-blocking@~2.0.0:
20552059
version "2.0.0"
20562060
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"

0 commit comments

Comments
 (0)