CloudFlare Pages
# CloudFlare Pages新功能

如果你是一個需要常常部署網站或維護網站的工程師,你應該要知道CloudFlare,最近發現了它有一個新功能叫做Pages,可以很方便且快速的在我們把程式碼推上github時,就自動把網頁程式直接部署到CloudFlare的空間,還提供每一次部署的網頁版本,並且可以直接綁定你申請個人的網域名稱,是不是太方便了。
# What is CloudFlare?
CloudFlare 是一家內容傳遞網路( Content Delivery Network, CDN)、域名系統( Domain Name Server, DNS)、阻斷服務攻擊( distributed denial-of-service attack, DDoS)與網路安全服務的一間公司,我想大家都跟我一樣,會知道CloudFlare的主要原因是因為它免費提供 DDoS 防護、免費 SSL 加密協議、免費 CDN 加速,真的是解決了我們許多維護網站上的許多工作。
# What is Pages Function?
Cloudflare Pages is a JAMstack platform for frontend developers to collaborate and deploy websites.這是官方的說明,要說明的是JAM其實就是 JavaScript、API 和 Markup組合的簡稱。目前的Pages功能整合了GitHub,然後三個步驟
- 1.Choose repository
- 2.Set up builds and deployments
- 3.Deploy site
就完成Pages上的設定,接下來只要在你的開發環境上,完成git commit 和 git push,很神奇的事情就發生了,CloudFlare Pages就會開始幫你build你推上去github的程式碼,並同時deploy到CloudFlare的雲端空間上,並且還可以提供你每一次deploy完後的URL記錄。
我這個VuePress網站也是用這樣的方法來部署的喔,非常的方便。😁
以下就是CloudFlare Page從Initializing到Deploy完成的console log:
15:15:44.768 Initializing build environment. This may take up to a few minutes to complete
15:16:16.238 Success: Finished initializing build environment
15:16:16.238 Cloning repository...
15:16:19.832 Success: Finished cloning repository files
15:16:20.584 Installing dependencies
15:16:20.608 Python version set to 2.7
15:16:24.189 v12.18.0 is already installed.
15:16:24.531 Now using node v12.18.0 (npm v6.14.4)
15:16:24.552 Started restoring cached build plugins
15:16:24.562 Finished restoring cached build plugins
15:16:24.932 Attempting ruby version 2.7.1, read from environment
15:16:26.159 Using ruby version 2.7.1
15:16:26.464 Using PHP version 5.6
15:16:26.494 5.2 is already installed.
15:16:26.497 Using Swift version 5.2
15:16:26.497 Started restoring cached node modules
15:16:26.499 Finished restoring cached node modules
15:16:26.624 Installing NPM modules using NPM version 6.14.4
15:16:29.857 npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
15:16:31.925 npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
15:16:32.769 npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
15:16:32.965 npm WARN deprecated axios@0.16.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
15:16:33.112 npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
15:16:37.287 npm WARN deprecated har-validator@5.1.5: this library is no longer supported
15:16:37.313 npm WARN deprecated mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
15:16:39.869 npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
15:16:40.559 npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
15:17:02.151
15:17:02.151 > core-js@3.12.0 postinstall /opt/buildhome/repo/node_modules/core-js
15:17:02.151 > node -e "try{require('./postinstall')}catch(e){}"
15:17:02.151
15:17:02.195 [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
15:17:02.195
15:17:02.195 [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
15:17:02.195 [96m>[94m https://opencollective.com/core-js [0m
15:17:02.195 [96m>[94m https://www.patreon.com/zloirock [0m
15:17:02.195
15:17:02.195 [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
15:17:02.195
15:17:02.218
15:17:02.218 > ejs@2.7.4 postinstall /opt/buildhome/repo/node_modules/ejs
15:17:02.218 > node ./postinstall.js
15:17:02.218
15:17:02.253 Thank you for installing [35mEJS[0m: built with the [32mJake[0m JavaScript build tool ([32mhttps://jakejs.com/[0m)
15:17:02.253
15:17:02.691
15:17:02.691 > vuepress@1.8.0 postinstall /opt/buildhome/repo/node_modules/vuepress
15:17:02.691 > opencollective-postinstall || exit 0
15:17:02.691
15:17:02.728 [96m[1mThank you for using vuepress![96m[1m
15:17:02.729 [0m[96mIf you rely on this package, please consider supporting our open collective:[22m[39m
15:17:02.729 > [94mhttps://opencollective.com/vuepress/donate[0m
15:17:02.729
15:17:03.528 npm notice created a lockfile as package-lock.json. You should commit this file.
15:17:03.529 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
15:17:03.529 npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
15:17:03.529 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/watchpack/node_modules/chokidar/node_modules/fsevents):
15:17:03.530 npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
15:17:03.530 npm WARN react-flip-move@2.9.14 requires a peer of react@0.13.x || 0.14.x || 15.x.x but none is installed. You must install peer dependencies yourself.
15:17:03.530 npm WARN react-flip-move@2.9.14 requires a peer of react-dom@0.13.x || 0.14.x || 15.x.x but none is installed. You must install peer dependencies yourself.
15:17:03.531 npm WARN theme-vdoing-blog@1.0.0 No repository field.
15:17:03.531
15:17:03.537 added 1888 packages from 1421 contributors and audited 1890 packages in 34.991s
15:17:04.131
15:17:04.131 74 packages are looking for funding
15:17:04.131 run `npm fund` for details
15:17:04.131
15:17:04.131 found 51 vulnerabilities (49 moderate, 2 high)
15:17:04.131 run `npm audit fix` to fix them, or `npm audit` for details
15:17:04.158 NPM modules installed
15:17:04.601 Installing Hugo 0.54.0
15:17:05.514 Hugo Static Site Generator v0.54.0-B1A82C61A/extended linux/amd64 BuildDate: 2019-02-01T10:04:38Z
15:17:05.515 Started restoring cached go cache
15:17:05.517 Finished restoring cached go cache
15:17:06.309 go version go1.14.4 linux/amd64
15:17:06.312 go version go1.14.4 linux/amd64
15:17:06.321 Installing missing commands
15:17:06.321 Verify run directory
15:17:06.321 Executing user command: npm run build
15:17:07.082
15:17:07.082 > theme-vdoing-blog@1.0.0 build /opt/buildhome/repo
15:17:07.082 > vuepress build docs
15:17:07.082
15:17:07.827 wait Extracting site metadata...
15:17:07.849 tip add sidebar data. 完成產生側邊選單列表。
15:17:07.849 tip Apply theme vuepress-theme-theme-vdoing ...
15:17:07.871 tip Apply plugin container (i.e. "vuepress-plugin-container") ...
15:17:07.872 tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
15:17:07.872 tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
15:17:07.873 tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
15:17:07.873 tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
15:17:07.876 tip Apply plugin baidu-autopush (i.e. "vuepress-plugin-baidu-autopush") ...
15:17:07.876 tip Apply plugin thirdparty-search (i.e. "vuepress-plugin-thirdparty-search") ...
15:17:07.876 tip Apply plugin one-click-copy (i.e. "vuepress-plugin-one-click-copy") ...
15:17:07.877 tip Apply plugin demo-block (i.e. "vuepress-plugin-demo-block") ...
15:17:07.877 tip Apply plugin zooming (i.e. "vuepress-plugin-zooming") ...
15:17:07.878 tip Apply plugin baidu-tongji (i.e. "vuepress-plugin-baidu-tongji") ...
15:17:07.878 tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
15:17:08.615 ℹ Compiling Client
15:17:08.629 ℹ Compiling Server
15:17:22.608 ✔ Server: Compiled successfully in 13.98s
15:17:29.460 ✔ Client: Compiled successfully in 20.85s
15:17:29.536 wait Rendering static HTML...
15:17:30.073 [2K[1Gsuccess Generated static files in docs/.vuepress/dist.
15:17:30.073
15:17:30.107 Finished
15:17:30.107 Validating asset output directory
15:17:30.555 Deploying your site to Cloudflare's global network...
15:17:37.353 Success: Your site was deployed!
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