Skip to content

Commit 96fd2cf

Browse files
committed
Fix Firebase functions deploy
1 parent 6bcc584 commit 96fd2cf

File tree

7 files changed

+48
-18
lines changed

7 files changed

+48
-18
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ Before starting, make sure that you have Node 16 installed or use [nvm](https://
122122

123123
1. [Install Google's Cloud SDK](https://cloud.google.com/sdk/docs/install) and run `gcloud auth login` to log in.
124124
2. Run `npm install -g firebase-tools` to install Firebase CLI and run `firebase login` to log in.
125-
3. Run `npm install` in the *root* directory of the cloned/forked repo.
125+
3. Run `npm install` in the _root_ directory of the cloned/forked repo.
126126
4. Go to [Firebase console](https://console.firebase.google.com/u/0/) and create two projects, one for **development** environment and one for **production** environment.
127-
5. In Firebase console, create *Web* apps for the two projects you created. Refer to this [article](https://support.google.com/firebase/answer/9326094) for additional information.
127+
5. In Firebase console, create _Web_ apps for the two projects you created. Refer to this [article](https://support.google.com/firebase/answer/9326094) for additional information.
128128
6. In Firebase console, open Project Settings and note the Project IDs for the projects you created.
129-
7. Create a `.firebaserc` file in the *root* of this repo and add the Project IDs there like this (dummy values):
129+
7. Create a `.firebaserc` file in the _root_ of this repo and add the Project IDs there like this (dummy values):
130130

131131
```json
132132
{
@@ -147,7 +147,7 @@ Before starting, make sure that you have Node 16 installed or use [nvm](https://
147147
REACT_APP_FIREBASE_API_KEY="AIzaSkR_FfdseFcsE3fgg7pdjjjof6jhDSA-dTM"
148148
REACT_APP_FIREBASE_AUTH_DOMAIN="zaino-dev-3ea56.firebaseapp.com"
149149
REACT_APP_FIREBASE_DATABASE_URL="https://zaino-dev-3ea56.firebaseio.com"
150-
REACT_APP_FIREBASE_PROJECT_ID="zaino-dev-3ea56"
150+
REACT_APP_FB_PROJECT_ID="zaino-dev-3ea56"
151151
REACT_APP_FIREBASE_STORAGE_BUCKET="zaino-dev-3ea56.appspot.com"
152152
REACT_APP_FIREBASE_MESSAGING_SENDER_ID="550657824795"
153153
REACT_APP_FIREBASE_APP_ID="1:550657824795:web:29da52b66934c3ea494f74"
@@ -190,7 +190,7 @@ REACT_APP_FIREBASE_MEASUREMENT_ID="G-EWJOIOADSK"
190190
2. Go to `packages/firebase` and create `.env.development` and `.env.production` files with the variables for your Project IDs. The file format should be like this:
191191

192192
```shell
193-
FIREBASE_PROJECT_ID="zaino-dev-3ea56"
193+
FB_PROJECT_ID="zaino-dev-3ea56"
194194
```
195195

196196
Note: You can change additional settings like regions and Cloud Storage bucket name in [the `.env` file](packages/firebase/.env).

package-lock.json

+36-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/firebase/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FIREBASE_FUNCTIONS_REGION="europe-west1"
1+
FB_FUNCTIONS_REGION="europe-west1"
22
GCP_STORAGE_BACKUPS_REGION="EU"
33
GCP_STORAGE_BACKUPS_BUCKET="zaino-backups"

packages/firebase/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"main": "build/firebase/src/index.js",
1919
"dependencies": {
2020
"@google-cloud/firestore": "^5.0.2",
21-
"firebase-admin": "^10.0.2",
22-
"firebase-functions": "^3.6.1",
2321
"dotenv": "^14.2.0",
22+
"firebase-admin": "^10.0.2",
23+
"firebase-functions": "^4.4.1",
2424
"ts-node": "^10.4.0",
2525
"typescript": "^4.0.2"
2626
},

packages/firebase/scripts/deploy.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
export $(echo $(cat .env | sed 's/#.*//g' | sed 's/\r//g' | xargs) | envsubst)
66
export $(echo $(cat .env."$1" | sed 's/#.*//g' | sed 's/\r//g' | xargs) | envsubst)
77

8-
gcloud config set project "$FIREBASE_PROJECT_ID"
8+
gcloud config set project "$FB_PROJECT_ID"
99

10-
firebase -P "$1" functions:config:set settings.functions.region="$FIREBASE_FUNCTIONS_REGION"
10+
firebase -P "$1" functions:config:set settings.functions.region="$FB_FUNCTIONS_REGION"
1111
firebase -P "$1" functions:config:set settings.backups.bucket="$GCP_STORAGE_BACKUPS_BUCKET"
1212
rm -rf ./build
1313
tsc

packages/web-app/scripts/deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export $(echo $(cat .env."$1" | sed 's/#.*//g' | sed 's/\r//g' | xargs) | envsub
66

77
node scripts/build.js
88

9-
gcloud config set project "$REACT_APP_FIREBASE_PROJECT_ID"
9+
gcloud config set project "$REACT_APP_FB_PROJECT_ID"
1010
gsutil -m cp -r "src/images/copyrighted/*" gs://"$REACT_APP_FIREBASE_STORAGE_BUCKET"/
1111
gsutil -m acl set -R -a public-read gs://"$REACT_APP_FIREBASE_STORAGE_BUCKET"/
1212

packages/web-app/src/firebase/firebaseConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config = {
1010
databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
1111
measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID,
1212
messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
13-
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
13+
projectId: process.env.REACT_APP_FB_PROJECT_ID,
1414
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
1515
};
1616

0 commit comments

Comments
 (0)