Skip to content

Commit 5687c40

Browse files
committed
initial commit
0 parents  commit 5687c40

13 files changed

+4814
-0
lines changed

.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"targets": {
5+
"node": "6.10"
6+
}
7+
}]
8+
]
9+
}

.gitignore

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
dist
2+
package.zip
3+
.local-chromium
4+
local-chromium.tar.gz
5+
6+
### https://raw.github.com/github/gitignore/49d13cdba39774f7fa224ef13f4a1153200e2710/Global/macOS.gitignore
7+
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
34+
35+
36+
### https://raw.github.com/github/gitignore/49d13cdba39774f7fa224ef13f4a1153200e2710/Node.gitignore
37+
38+
# Logs
39+
logs
40+
*.log
41+
npm-debug.log*
42+
43+
# Runtime data
44+
pids
45+
*.pid
46+
*.seed
47+
*.pid.lock
48+
49+
# Directory for instrumented libs generated by jscoverage/JSCover
50+
lib-cov
51+
52+
# Coverage directory used by tools like istanbul
53+
coverage
54+
55+
# nyc test coverage
56+
.nyc_output
57+
58+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
59+
.grunt
60+
61+
# node-waf configuration
62+
.lock-wscript
63+
64+
# Compiled binary addons (http://nodejs.org/api/addons.html)
65+
build/Release
66+
67+
# Dependency directories
68+
node_modules
69+
jspm_packages
70+
71+
# Optional npm cache directory
72+
.npm
73+
74+
# Optional eslint cache
75+
.eslintcache
76+
77+
# Optional REPL history
78+
.node_repl_history
79+
80+
# Output of 'npm pack'
81+
*.tgz
82+
83+
# Yarn Integrity file
84+
.yarn-integrity
85+
86+
87+

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Taiki Sakamoto
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# puppteeer-lambda-boilerplate
2+
3+
Boilerplate for running Headless-Chrome by [Puppeteer](https://github.com/GoogleChrome/puppeteer) on AWS Lambda.
4+
5+
## Packaging & Deploy
6+
7+
Lambda's memory is set to 384 MB or more.
8+
9+
### chrome in package (recommend)
10+
11+
Run `npm run package`, and deploy the package.zip.
12+
13+
### chrome NOT in package
14+
15+
Due to the large size of Chrome, it may exceed the [Lambda package size limit](http://docs.aws.amazon.com/lambda/latest/dg/limits.html) (50 MB) depending on the other module to include.
16+
In that case, put Chrome in S3 and download it at container startup so startup time will be longer.
17+
18+
Run `npm run package-nochrome`, deploy the package.zip, and set following env valiables on Lambda.
19+
20+
- `CHROME_BUCKET`(required): S3 bucket where Chrome is put
21+
- `CHROME_KEY`(optional): S3 key. default: headless_shell.tar.gz
22+
23+
## Build Headless-Chrome (optional)
24+
25+
If you want to use latest chrome, run chrome/buildChrome.sh on EC2 having at least 16GB memory and 30GB volume.
26+
See also [serverless-chrome](https://github.com/adieuadieu/serverless-chrome/blob/master/chrome/README.md).
27+
Once you build it, link to headless_shell.tar.gz in /chrome.
28+
29+
## Reference
30+
31+
[記事](https://www.sambaiz.net/article/132/)
44.4 MB
Binary file not shown.

chrome/buildChrome.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# build headless chrome on EC2
2+
# https://github.com/adieuadieu/serverless-chrome/blob/master/chrome/README.md
3+
4+
# sudo su
5+
6+
yum install -y git redhat-lsb python bzip2 tar pkgconfig atk-devel alsa-lib-devel bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel freetype-devel gcc-c++ GConf2-devel glib2-devel glibc.i686 gperf glib2-devel gtk2-devel gtk3-devel java-1.*.0-openjdk-devel libatomic libcap-devel libffi-devel libgcc.i686 libgnome-keyring-devel libjpeg-devel libstdc++.i686 libX11-devel libXScrnSaver-devel libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs nspr-devel nss-devel pam-devel pango-devel pciutils-devel pulseaudio-libs-devel zlib.i686 httpd mod_ssl php php-cli python-psutil wdiff --enablerepo=epel
7+
8+
cd ~
9+
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
10+
echo "export PATH=$PATH:$HOME/depot_tools" >> ~/.bash_profile
11+
source ~/.bash_profile
12+
13+
mkdir Chromium
14+
cd Chromium
15+
fetch --no-history chromium
16+
cd src
17+
18+
# use /tmp instead of /dev/shm
19+
# https://groups.google.com/a/chromium.org/forum/#!msg/headless-dev/qqbZVZ2IwEw/CPInd55OBgAJ
20+
sed -i -e "s/use_dev_shm = true;/use_dev_shm = false;/g" base/files/file_util_posix.cc
21+
22+
mkdir -p out/Headless
23+
echo 'import("//build/args/headless.gn")' > out/Headless/args.gn
24+
echo 'is_debug = false' >> out/Headless/args.gn
25+
echo 'symbol_level = 0' >> out/Headless/args.gn
26+
echo 'is_component_build = false' >> out/Headless/args.gn
27+
echo 'remove_webcore_debug_symbols = true' >> out/Headless/args.gn
28+
echo 'enable_nacl = false' >> out/Headless/args.gn
29+
gn gen out/Headless
30+
ninja -C out/Headless headless_shell
31+
32+
cd out/Headless
33+
tar -zcvf /home/ec2-user/headless_shell.tar.gz headless_shell
34+
35+
# scp [email protected]:~/headless_shell.tar.gz .

chrome/headless_shell.tar.gz

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HeadlessChrome-63.0.3213.0.tar.gz

0 commit comments

Comments
 (0)