You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-30Lines changed: 36 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,19 +44,15 @@ A basic web app client in the **/client** directory will show basic API usage an
44
44
cd server
45
45
npm install
46
46
```
47
-
3. Set up the environment variables. Create a `.env` file inside the **/server** directory with reference to the `.env.example` file. Encode your own Firebase project settings on the following variables:
48
-
-`FIREBASE_SERVICE_ACC`
49
-
- The project's private key file contents, condensed into one line and minus all whitespace characters.
50
-
- The service account JSON file is generated from the Firebase project's **Project Settings** page, on
51
-
**Project Settings** -> **Service accounts** -> **Generate new private key**
52
-
-`FIREBASE_PRIVATE_KEY`
53
-
- The `private_key` entry from the service account JSON file
54
-
-> **NOTE:** Take note to make sure that the value starts and ends with a double-quote on WINDOWS OS localhost. Some systems may or may not require the double-quotes (i.e., Ubuntu running on heroku).
55
-
-`ALLOWED_ORIGINS`
56
-
- IP/domain origins in comma-separated values that are allowed to access the API
57
-
- Include `http://localhost:3000` by default to allow CORS access to the `/client` app.
58
-
-`EMAIL_WHITELIST`
59
-
- Comma-separated email addresses linked to Firebase Auth UserRecords that are not allowed to be deleted or updated (write-protected)
47
+
3. Set up the environment variables. Create a `.env` file inside the **/server** directory with reference to the `.env.example` file. Encode your own Firebase project settings on the following variables:
48
+
49
+
| Variable Name | Description |
50
+
| --- | --- |
51
+
|FIREBASE_SERVICE_ACC| The project's private key file contents, condensed into one line and minus all whitespace characters.<br><br>The service account JSON file is generated from the Firebase project's **Project Settings** page, on **Project Settings** -> **Service accounts** -> **Generate new private key**|
52
+
|FIREBASE_PRIVATE_KEY| The `private_key` entry from the service account JSON file.<br> <blockquote> **NOTE:** Take note to make sure that the value starts and ends with a double-quote on WINDOWS OS localhost. Some systems may or may not require the double-quotes (i.e., Ubuntu running on heroku).</blockquote> |
53
+
|ALLOWED_ORIGINS|IP/domain origins in comma-separated values that are allowed to access the API. Include `http://localhost:3000` by default to allow CORS access to the `/client` app.|
54
+
|EMAIL_WHITELIST| Comma-separated email addresses linked to Firebase Auth UserRecords that are not allowed to be deleted or updated (write-protected)<br><br>Default value is `[email protected]`|
55
+
|ALLOW_CORS|Allow Cross-Origin Resource Sharing (CORS) on the API endpoints.<br><br>Default value is `1`. Setting to `0` will make all endpoints accept requests from all domains, including Postman.|
60
56
61
57
### client
62
58
@@ -65,12 +61,15 @@ A basic web app client in the **/client** directory will show basic API usage an
65
61
cd client
66
62
npm install
67
63
```
68
-
2. Replace `/client/utils/firebase/firebase.config.js` with your own Firebase project's web SDK setup configuration file.
64
+
2. Replace the `/client/utils/firebase/firebase.config.js` file with your own Firebase project's web SDK setup configuration file.
69
65
- You can find this file in a Firebase project's
70
66
**Project Settings** -> **General** -> **Web apps** (Add an app if needed) -> **SDK setup and configuration**
71
-
3. Create a `/client/.env` file from the `/client/.env.example` file.
72
-
- The `firebase.config.js` settings must match with the `FIREBASE_SERVICE_ACC` environment variable provided on **server - step # 3.**
73
-
- Replace `REACT_APP_BASE_URL` with the domain on which the CRUD API is running (default value is `http://localhost:3001/api` on localhost. See the [server](#server) set-up instructions for more information).
67
+
- The `firebase.config.js` settings must match with the `FIREBASE_SERVICE_ACC` environment variable defined on **server - step # 3.**
68
+
3. Create a `/client/.env` file from the `/client/.env.example` file. Replace the `REACT_APP_BASE_URL` variable with an appropriate value.
69
+
70
+
| Variable Name | Description |
71
+
| --- | --- |
72
+
|REACT_APP_BASE_URL|Domain on which the CRUD API is running.<br><br> Default value is `http://localhost:3001/api` on localhost. See the [server](#server) set-up instructions for more information.|
74
73
4. Run the app in development mode.
75
74
`npm start`
76
75
5. Launch the client app in:
@@ -153,38 +152,42 @@ We can use Docker to run dockerized **client** and **server** apps for local dev
153
152
-> **INFO:** Building the images for localhost development takes a while, around ~7min+.
154
153
4. Create and start the client and server containers.
155
154
`docker-compose -f docker-compose-dev.yml up`
156
-
5. Launch the dockerized (dev) client app on
155
+
5. Run a script in the container to create the default `[email protected]` account, if it does not yet exist in the Firestore database.
156
+
`docker exec -it server-prod npm run seed`
157
+
6. Launch the dockerized (dev) client app on
157
158
`http://localhost:3000`
158
-
6. Launch the dockerized (dev) server app's API documentation on
159
+
7. Launch the dockerized (dev) server app's API documentation on
159
160
`http://localhost:3001/docs`
160
-
7. Edit source the codes in `/client/src` or `/server/src` as needed. Verify that hot reload is working on both the client and server apps.
161
-
8. Stop and remove containers, networks, images and volumes:
161
+
8. Edit source the codes in `/client/src` or `/server/src` as needed. Verify that hot reload is working on both the client and server apps.
162
+
9. Stop and remove containers, networks, images and volumes:
162
163
`docker-compose -f docker-compose-dev.yml down`
163
164
164
165
### Docker for Production Deployment
165
166
166
-
The following docker-compose commands build small client and server images targeted for creating optimized dockerized apps running on production servers. Hot reload is not available when editing source codes from `/client/src` or `/server/src`.
167
+
The following docker-compose commands build small client and server images targeted for creating optimized dockerized apps running on self-managed production servers. Hot reload is not available when editing source codes from `/client/src` or `/server/src`.
167
168
168
-
1. Install and set up the required environment variables as with the required variables on **Docker for Localhost Development**.
169
+
1. Install and set up the required **client** and **server**environment variables as with the required variables on [**Docker for Localhost Development**](#docker-for-localhost-development).
169
170
2. Build the client and server docker services for production deployment.
3. At this point, we can opt to push the docker images to a docker registry of your choice. (Requires sign-in to the selected docker registry).
172
173
-`docker-compose -f docker-compose-prod.yml push`
173
174
4. Create and start the client and server containers.
174
175
`docker-compose -f docker-compose-prod.yml up`
175
-
5. Launch the dockerized (prod) client app on
176
+
5. Run a script in the container to create the default `[email protected]` account, if it does not yet exist in the Firestore database.
177
+
`docker exec -it server-prod npm run seed`
178
+
6. Launch the dockerized (prod) client app on
176
179
`http://localhost:3000`
177
-
6. Launch the dockerized (prod) server app's API documentation on
180
+
7. Launch the dockerized (prod) server app's API documentation on
178
181
`http://localhost:3001/docs`
179
-
7. Stop and remove containers, networks, images and volumes:
182
+
8. Stop and remove containers, networks, images and volumes:
180
183
`docker-compose -f docker-compose-prod.yml down`
181
184
182
185
## Pre-built Server Docker Image
183
186
184
-
**firebase-users-admin**'s `server` component is available as a stand-alone docker image on Docker Hub.
187
+
**firebase-users-admin**'s `server` component is available as a stand-alone docker image on Docker Hub with customizable environment variables (.env file).
185
188
186
189
1. Pull the (production) **/server** docker image from Docker Hub.
0 commit comments