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
+59-26Lines changed: 59 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ A basic web app client in the **/client** directory will show basic API usage an
13
13
-[Installation and Usage Using Docker](#installation-and-usage-using-docker)
14
14
-[Docker for Localhost Development](#docker-for-localhost-development)
15
15
-[Docker for Production Deployment](#docker-for-production-deployment)
16
+
-[Pre-built Server Docker Image](#pre-built-server-docker-image)
16
17
-[References](#references)
17
18
18
19
## Requirements
@@ -43,19 +44,15 @@ A basic web app client in the **/client** directory will show basic API usage an
43
44
cd server
44
45
npm install
45
46
```
46
-
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:
47
-
-`FIREBASE_SERVICE_ACC`
48
-
- The project's private key file contents, condensed into one line and minus all whitespace characters.
49
-
- The service account JSON file is generated from the Firebase project's **Project Settings** page, on
50
-
**Project Settings** -> **Service accounts** -> **Generate new private key**
51
-
-`FIREBASE_PRIVATE_KEY`
52
-
- The `private_key` entry from the service account JSON file
53
-
-> **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).
54
-
-`ALLOWED_ORIGINS`
55
-
- IP/domain origins in comma-separated values that are allowed to access the API
56
-
- Include `http://localhost:3000` by default to allow CORS access to the `/client` app.
57
-
-`EMAIL_WHITELIST`
58
-
- 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.|
59
56
60
57
### client
61
58
@@ -64,12 +61,15 @@ A basic web app client in the **/client** directory will show basic API usage an
64
61
cd client
65
62
npm install
66
63
```
67
-
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.
68
65
- You can find this file in a Firebase project's
69
66
**Project Settings** -> **General** -> **Web apps** (Add an app if needed) -> **SDK setup and configuration**
70
-
3. Create a `/client/.env` file from the `/client/.env.example` file.
71
-
- The `firebase.config.js` settings must match with the `FIREBASE_SERVICE_ACC` environment variable provided on **server - step # 3.**
72
-
- 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.|
73
73
4. Run the app in development mode.
74
74
`npm start`
75
75
5. Launch the client app in:
@@ -152,32 +152,65 @@ We can use Docker to run dockerized **client** and **server** apps for local dev
152
152
-> **INFO:** Building the images for localhost development takes a while, around ~7min+.
153
153
4. Create and start the client and server containers.
154
154
`docker-compose -f docker-compose-dev.yml up`
155
-
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
156
158
`http://localhost:3000`
157
-
6. Launch the dockerized (dev) server app's API documentation on
159
+
7. Launch the dockerized (dev) server app's API documentation on
158
160
`http://localhost:3001/docs`
159
-
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.
160
-
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:
161
163
`docker-compose -f docker-compose-dev.yml down`
162
164
163
165
### Docker for Production Deployment
164
166
165
-
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`.
166
168
167
-
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).
168
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).
171
173
-`docker-compose -f docker-compose-prod.yml push`
172
174
4. Create and start the client and server containers.
173
175
`docker-compose -f docker-compose-prod.yml up`
174
-
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
175
179
`http://localhost:3000`
176
-
6. Launch the dockerized (prod) server app's API documentation on
180
+
7. Launch the dockerized (prod) server app's API documentation on
177
181
`http://localhost:3001/docs`
178
-
7. Stop and remove containers, networks, images and volumes:
182
+
8. Stop and remove containers, networks, images and volumes:
179
183
`docker-compose -f docker-compose-prod.yml down`
180
184
185
+
## Pre-built Server Docker Image
186
+
187
+
**firebase-users-admin**'s `server` component is available as a stand-alone docker image on Docker Hub with customizable environment variables (.env file).
188
+
189
+
1. Pull the (production) **/server** docker image from Docker Hub.
0 commit comments