Skip to content

Commit

Permalink
completed multiple deployment using firebase functions
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-karlovskiy committed Jul 30, 2019
1 parent b8cd4ca commit 100467c
Show file tree
Hide file tree
Showing 55 changed files with 2,025 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "env-aware"
}
}
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
multipleBuildsPath="../builds/"
multipleBuildsPath="../functions/builds/"
individualBuildAllFiles="build/*"

craBatteryConsiderateLoading="cra-battery-considerate-loading"
Expand All @@ -18,9 +18,9 @@ cd $craBatteryConsiderateLoading
rm -rf node_modules build
npm install
npm run build
# mkdir -p ../builds/cra-battery-considerate-loading
# mkdir -p ../functions/builds/cra-battery-considerate-loading
mkdir -p "${multipleBuildsPath}${craBatteryConsiderateLoading}"
# cp -r build/* ../builds/cra-battery-considerate-loading
# cp -r build/* ../functions/builds/cra-battery-considerate-loading
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craBatteryConsiderateLoading}"
cd ..

Expand Down
4 changes: 3 additions & 1 deletion clean.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
multipleBuildsPath="../builds/"
multipleBuildsPath="../functions/builds/"
individualBuildAllFiles="build/*"

craBatteryConsiderateLoading="cra-battery-considerate-loading"
Expand All @@ -13,7 +13,9 @@ craUaAwareCodeSplitting="cra-ua-aware-code-splitting"
reactMovieNetworkAwareComponents="react-movie-network-aware-components"
reactShrineNetworkAwareCodeSplitting="react-shrine-network-aware-code-splitting"

cd functions
rm -rf node_modules builds
cd ..

cd $craBatteryConsiderateLoading
rm -rf node_modules build
Expand Down
66 changes: 66 additions & 0 deletions firebase-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[debug] [2019-07-29T20:50:45.874Z] ----------------------------------------------------------------------
[debug] [2019-07-29T20:50:45.876Z] Command: C:\Program Files\nodejs\node.exe C:\Users\JIN\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy
[debug] [2019-07-29T20:50:45.876Z] CLI Version: 7.2.1
[debug] [2019-07-29T20:50:45.877Z] Platform: win32
[debug] [2019-07-29T20:50:45.877Z] Node Version: v10.15.3
[debug] [2019-07-29T20:50:45.877Z] Time: Mon Jul 29 2019 23:50:45 GMT+0300 (Moscow Standard Time)
[debug] [2019-07-29T20:50:45.877Z] ----------------------------------------------------------------------
[debug]
[debug] [2019-07-29T20:50:45.883Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2019-07-29T20:50:45.883Z] > authorizing via signed-in user
[debug] [2019-07-29T20:50:45.883Z] [iam] checking project env-aware for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2019-07-29T20:50:45.884Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/env-aware:testIamPermissions

[debug] [2019-07-29T20:50:47.084Z] <<< HTTP RESPONSE 200
[info]
[info] === Deploying to 'env-aware'...
[info]
[info] i deploying functions
[debug] [2019-07-29T20:50:51.023Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0",
"cors": "^2.8.5",
"deviceatlas-deviceapi": "file:lib/device-atlas/deviceatlas-enterprise-nodejs-2.1.3/Api/deviceatlas-deviceapi-2.1.3.tgz",
"express": "^4.17.1",
"mkdirp": "^0.5.1",
"string-similarity": "^3.0.0"
},
"devDependencies": {
"firebase-functions-test": "^0.1.6"
},
"private": true
}
[info] i functions: ensuring necessary APIs are enabled...
[debug] [2019-07-29T20:50:51.023Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/env-aware/services/cloudfunctions.googleapis.com

[debug] [2019-07-29T20:50:51.024Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/env-aware/services/runtimeconfig.googleapis.com

[debug] [2019-07-29T20:50:52.565Z] <<< HTTP RESPONSE 200
[debug] [2019-07-29T20:50:52.586Z] <<< HTTP RESPONSE 200
[info] + functions: all necessary APIs are enabled
[debug] [2019-07-29T20:50:52.587Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/env-aware/adminSdkConfig

[debug] [2019-07-29T20:50:53.403Z] <<< HTTP RESPONSE 200
[info] i functions: preparing functions directory for uploading...
[debug] [2019-07-29T20:50:53.405Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/env-aware/configs

[debug] [2019-07-29T20:50:53.961Z] <<< HTTP RESPONSE 200
[info] i functions: packaged functions (11.23 MB) for uploading
[debug] [2019-07-29T20:50:56.306Z] >>> HTTP REQUEST POST https://cloudfunctions.googleapis.com/v1/projects/env-aware/locations/us-central1/functions:generateUploadUrl

[debug] [2019-07-29T20:51:30.013Z] <<< HTTP RESPONSE 200
[debug] [2019-07-29T20:51:30.013Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1-9687512f-d70b-43eb-94e5-0f81623f4e03/a5529413-47b9-4f07-9851-326a8154adfb.zip?GoogleAccessId=service-1029663082851@gcf-admin-robot.iam.gserviceaccount.com&Expires=1564435290&Signature=fBsqdp8kXti0gNDWzKgEfhc%2BKqn4sIGOU7bG2CIVzDrvhuYpjAUU4uXzxneayiulqEhbve%2BRaZPZrD4Zv3v8r5kFGRE%2FZ34vCR9aBBxS49Zj2PMaCRc8AeFl5B6WXTOaVVepq0MELicaDNCl937ppZTY2XPRkn9TnBvIAyk2pGkcT8tLfu1CprOowwWcXco22r%2FSP0RqVB51AJqF7bk%2BbJc63xj4XKTl59Iwz1IT9k8GBZNbIfeMGD4IktPlXoTzvN0mkpEUzxnaR3PbaRucAqr%2F1FFDqhwOqQpKrXvYaWlTDNr7bLBx1J1Vbh5WQWTL9DfMjut1%2BVrpY2gNY%2Fa2CQ%3D%3D
<request body omitted>
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
builds/
node_modules/
firebase-debug.log
.firebase/
9 changes: 9 additions & 0 deletions functions/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hosting": {
"public": "builds",
"rewrites": [ {
"source": "**",
"function": "app"
} ]
}
}
17 changes: 17 additions & 0 deletions server.js → functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
* limitations under the License.
*/

const functions = require('firebase-functions');

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });

const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
Expand Down Expand Up @@ -41,6 +50,12 @@ const deviceApi = (() => {
return devApi;
})();

// ray test touch <
app.get('/ping', (req, res) => {
res.send('pong');
});
// ray test touch >

app.get('/api/device', (req, res) => {
console.log('[server] user-agent => ', req.headers['user-agent']);

Expand Down Expand Up @@ -94,3 +109,5 @@ app.listen(
console.log(`Frontend start on http://localhost:5000`);
}
);

exports.app = functions.https.onRequest(app);
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 100467c

Please sign in to comment.