@@ -36,50 +36,113 @@ serve new files to users, or update redirects, etc.
36
36
NOTE: Fileset uses the default App Engine Google Cloud Storage bucket
37
37
(` gs://appid.appspot.com ` ) to upload files.
38
38
39
- 1 . Install the Fileset CLI.
40
-
41
- ``` bash
42
- npm install --save-dev @blinkk/fileset
39
+ 1 . Within your project, create a directory to house the server files, e.g.
40
+ ` ./backend/fileset ` . Avoid mixing the server configuration with any tools to
41
+ build your website. The ` package.json ` , etc. should be kept separate in order
42
+ to keep the deployment slim.
43
+
44
+ 2 . Create a ` package.json ` like the below. App Engine will use ` npm start ` to
45
+ run the server.
46
+
47
+ ``` json
48
+ {
49
+ "scripts" : {
50
+ "start" : " fileset serve"
51
+ },
52
+ "dependencies" : {
53
+ "@blinkk/fileset" : " ^0.1.0"
54
+ }
55
+ }
43
56
```
44
57
45
- 2 . Create an ` app.yaml ` for Google App Engine deployment.
58
+ 3 . Create an ` app.yaml ` for Google App Engine deployment.
46
59
47
60
``` yaml
48
61
service : fileset
49
62
runtime : nodejs10
50
- entrypoint : fileset serve
51
63
` ` `
52
64
53
- 3. Deploy the app.
65
+ 4. Deploy the app and enable the Cloud Datastore API.
66
+
67
+ ` ` ` bash
68
+ gcloud app deploy --project=<AppID> app.yaml
69
+ gcloud services enable datastore.googleapis.com --project=<AppID>
70
+ ```
71
+
72
+ ### Deployment setup
73
+
74
+ NOTE: Before you can deploy, you'll need to authenticate. Refer to the
75
+ [ authentication documentation] ( #uploader-authentication ) if you have not used
76
+ Google Cloud Platform services before and need information on authentication.
77
+
78
+ 1 . Create a ` fileset.yaml ` configuration file.
79
+
80
+ ``` yaml
81
+ site : siteId # Specify a site ID. If blank, `default` will be used.
82
+ schedule :
83
+ default : master # Specify a branch for the prod deployment.
84
+ ` ` `
85
+
86
+ 2. Generate your files.
87
+
88
+ Use a static site generator or just manually create a directory containing files
89
+ to upload. In the below example, the files in the directory ` build` are
90
+ uploaded.
91
+
92
+ 4. Upload your files.
54
93
55
94
` ` ` bash
56
- gcloud app deploy app.yaml
95
+ fileset upload ./build
57
96
` ` `
58
97
59
- ### Authentication for deployment
98
+ NOTE : The uploader will look for `fileset.yaml` within the `./build` directory
99
+ first. If it's not found, it will look up in the parent folder for a
100
+ ` fileset.yaml` file. If the config file doesn't exist in the `./build` or parent
101
+ folder, the uploader will abort.
60
102
61
- Before you are able to deploy your files, you'll need to set up authentication
62
- to deploy .
103
+ 5. That's it! Files have been uploaded to Google Cloud Storage and the uploaded
104
+ directory is now being served by the application server .
63
105
64
- 1 . Identify the service account to use.
106
+ TODO : Document Identity-Aware Proxy setup and CLI authentication.
107
+
108
+ # # Uploader authentication
109
+
110
+ You'll need to be authenticated to deploy files and upload the serving manifests.
111
+
112
+ # ## Local testing / user account authentication
113
+
114
+ If you are testing locally, your user account can be used to authenticate to
115
+ Cloud Datastore and Cloud Storage. Simply run the below command to create
116
+ credentials used for authentication :
117
+
118
+ ` ` ` bash
119
+ gcloud auth application-default login
120
+ ` ` `
121
+
122
+ # ## Continuous deployment / service account authentication
123
+
124
+ If you are using a service account for deployment, you'll need to ensure it has
125
+ the right permissions.
126
+
127
+ # ### 1. Identify the service account to use.
65
128
66
129
Authentication to upload your files is done using a service account. You'll
67
130
generally want to use one of two service accounts :
68
131
69
- a. When the command is invoked from Google Cloud Build, your project's Cloud
70
- Build service account ( ` <ProjectNumber>@cloudbuild.gserviceaccount.com ` ) is
71
- used.
132
+ __Cloud Build service account__ : When the command is invoked from Google Cloud
133
+ Build, your project's Cloud Build service account
134
+ (`<ProjectNumber>@cloudbuild.gserviceaccount.com`) is used.
72
135
73
136
To determine your project's project number :
74
137
75
138
` ` ` bash
76
139
gcloud projects describe <AppID>
77
140
` ` `
78
141
79
- b. When the command is invoked locally (i.e. for testing or for manual uploads),
80
- you'll likely want to use your App Engine app's default service account
81
- (` <AppID>@appspot.gserviceaccount.com ` ). You can download a service account key
82
- by running:
142
+ __Application default service account__ : When the command is invoked locally
143
+ (i.e. for testing or for manual uploads), you'll likely want to use your App
144
+ Engine app's default service account (`<AppID>@appspot.gserviceaccount.com`).
145
+ You can download a service account key by running :
83
146
84
147
` ` ` bash
85
148
gcloud iam service-accounts keys create \
@@ -91,7 +154,7 @@ NOTE: This will download a `key.json` to your current directory. Avoid
91
154
committing this to your Git repository. You'll want to add `key.json` to
92
155
` .gitignore` .
93
156
94
- 2 . Ensure service account has permissions.
157
+ # ### 2. Ensure service account has permissions.
95
158
96
159
The following permissions are needed :
97
160
@@ -117,34 +180,6 @@ for role in datastore.owner storage.objectAdmin g; do \
117
180
--role=roles/$role \
118
181
; done
119
182
` ` `
120
-
121
- ### Deployment setup
122
-
123
- 1 . Create a ` fileset.yaml ` configuration file.
124
-
125
- ``` yaml
126
- site : siteId # Specify a site ID. If blank, `default` will be used.
127
- schedule :
128
- default : master # Specify a branch for the prod deployment.
129
- ` ` `
130
-
131
- 2. Generate your files.
132
-
133
- Use a static site generator or just manually create a directory containing files
134
- to upload. In the below example, the files in the directory ` build` are
135
- uploaded.
136
-
137
- 4. Upload your files.
138
-
139
- ` ` ` bash
140
- fileset upload -s siteId build
141
- ` ` `
142
-
143
- 5. That's it! Files have been uploaded to Google Cloud Storage and the uploaded
144
- directory is now being served by the application server.
145
-
146
- TODO : Document Identity-Aware Proxy setup and CLI authentication.
147
-
148
183
# # Environments
149
184
150
185
Fileset uses Git branches to determine whether files should be in production
@@ -175,3 +210,14 @@ Staging URL: https://default-f3a9abb-dot-fileset-dot-appid.appspot.com
175
210
...
176
211
Staging URL: https://default-4fb48ce-dot-fileset-dot-appid.appspot.com
177
212
` ` `
213
+
214
+ # # Testing
215
+
216
+ You can verify Fileset server is working as you expect by looking for the following headers :
217
+
218
+ | Header | Description |
219
+ |-|-|
220
+ | `x-fileset-site` | The site being served. Usually this will be `default` but for multi-site installations, this will be useful for determining which site is serving. |
221
+ | `x-fileset-ref` | The Git commit sha that corresponds to the serving manifest that is handling your request. |
222
+ | `x-fileset-blob` | The blob directory key corresponding to the file being served. This is the SHA-1 hash of the file's content. |
223
+ | `x-fileset-ttl` | For scheduled deployments, the value of this header will correspond to the timestamp for the timed deployment being served. |
0 commit comments