From 31ceee73cfb787dc16552f973368ad175c9adb92 Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 16:40:12 +0800 Subject: [PATCH 1/3] fix: include firebase config in gh secrets --- .github/workflows/release.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 655356f..25b0031 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,13 @@ jobs: runs-on: ubuntu-latest env: REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} + REACT_APP_FIREBASE_API_KEY: ${{ secrets.REACT_APP_FIREBASE_API_KEY }} + REACT_APP_FIREBASE_AUTHDOMAIN: ${{ secrets.REACT_APP_FIREBASE_AUTHDOMAIN }} + REACT_APP_FIREBASE_PROJECT_ID: ${{ secrets.REACT_APP_FIREBASE_PROJECT_ID }} + REACT_APP_FIREBASE_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_STORAGE_BUCKET }} + REACT_APP_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_MESSAGING_SENDER_ID }} + REACT_APP_FIREBASE_APP_ID: ${{ secrets.REACT_APP_FIREBASE_APP_ID }} + REACT_APP_FIREBASE_MEASUREMENT_ID: ${{ secrets.REACT_APP_FIREBASE_MEASUREMENT_ID }} strategy: matrix: node-version: [14.x] From 362fdb3d9e7870722450bd08791fe075ae00a1e4 Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 16:47:27 +0800 Subject: [PATCH 2/3] chore: bind full server mount volume --- docker-compose.dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index e2c60f5..a8498d9 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -30,7 +30,8 @@ services: networks: - firebase-users-dev volumes: - - ./server/src:/opt/server/src + - ./server:/opt/server + - /opt/server/node_modules ports: - "3001:3001" From 9e3c74cd6435bfd8f83b4aa6dfa96409727e65cb Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 16:52:46 +0800 Subject: [PATCH 3/3] chore: update api doc content --- README.md | 11 ++++--- server/src/utils/templates/header.md | 45 ++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 99cfe16..46e2707 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,6 @@ The server also serves the pre-built `client` website from a static directory us 1. Pull the (production) **/server** [Docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-app) from Docker Hub. - Find the latest version tag from https://hub.docker.com/r/ciatphdev/firebase-users-app, i.e., `v1.1.5` - `docker pull ciatphdev/firebase-users-app:v1.1.5` - - **NOTE:** 2. Create a `.env` file. - Read [**Installation - server #3**](#server) for more information. - Replace the variables accordingly in the `.env` file. Set `ALLOW_CORS=0` to allow `Same Origin` requests. Read [**Option #2 - Client and Server Bundled in (1) Image and Service**](#option-2---client-and-server-bundled-in-1-image-and-service) for more information. @@ -245,15 +244,15 @@ The server also serves the pre-built `client` website from a static directory us FIREBASE_SERVICE_ACC=YOUR-FIREBASE-PROJ-SERVICE-ACCOUNT-JSON-CREDENTIALS-ONE-LINER-NO-SPACES FIREBASE_PRIVATE_KEY=PRIVATE-KEY-FROM-FIREBASE-SERVICE-ACCOUNT-JSON-WITH-DOUBLE-QUOTES EMAIL_WHITELIST=superadmin@gmail.com - ALLOW_CORS=0 - ALLOW_AUTH=1 + ALLOW_CORS=0 + ALLOW_AUTH=1 ``` 3. Run the image. ``` docker run -it --rm \ --env-file .env \ -p 3001:3001 \ - ciatphdev/firebase-users-admin-app:v1.1.2 + ciatphdev/firebase-users-admin-app:v1.1.5 ``` 4. Run a script in the container to create the default `superadmin@gmail.com` account, if it does not yet exist in the Firestore database. `docker exec -it firebase-users-admin-app npm run seed` @@ -280,7 +279,7 @@ https://hub.docker.com/r/ciatphdev/firebase-users-server/tags ### Usage Options -- Use with the docker-compose.dev.yml file (requires a `.env` file inside the client and server folders):
+- Use with the docker-compose.dev.yml file (requires a `.env` file input parameter):
`docker compose -f docker-compose.dev.yml pull` - Docker pull
@@ -288,7 +287,7 @@ https://hub.docker.com/r/ciatphdev/firebase-users-server/tags docker pull ciatphdev/firebase-users-client:dev docker pull ciatphdev/firebase-users-server:dev ``` -- Docker run (requires a `.env` file inside the client and server folders):
+- Docker run (requires a `.env` file input parameter):
``` docker run -it --rm --env-file .env -p 3000:3000 ciatphdev/firebase-users-client:dev docker run -it --rm --env-file .env -p 3001:3001 ciatphdev/firebase-users-server:dev diff --git a/server/src/utils/templates/header.md b/server/src/utils/templates/header.md index fc054b8..7d9e9c1 100644 --- a/server/src/utils/templates/header.md +++ b/server/src/utils/templates/header.md @@ -11,9 +11,9 @@ username: superadmin@gmail.com password: 123456789 ``` -- **live client app:** [https://fire-auth-users.web.app/](https://fire-auth-users.web.app/) +- **live client app:** [https://adminusers-dev.web.app/](https://adminusers-dev.web.app/) - **localhost app:** [http://localhost:3000](http://localhost:3000) - - Read more about the localhost environment set-up instructions on [firebase-auth-users](https://github.com/ciatph/firebase-users-admin) + - Read more about the localhost environment set-up instructions on [firebase-admin-users](https://github.com/ciatph/firebase-users-admin) ### Docker @@ -21,9 +21,10 @@ firebase-users-admin's server component, hosting all the listed endpoints below The server also serves a pre-built [`client`](https://github.com/ciatph/firebase-users-admin/tree/dev/client) website from a static directory using the `express.static()` middleware, following the build instructions from [**Option #2 - Client and Server Bundled in (1) Image and Service**](https://github.com/ciatph/firebase-users-admin#option-2---client-and-server-bundled-in-1-image-and-service). -1. Pull the (production) **/server** [docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-server) from Docker Hub. - `docker pull ciatphdev/firebase-users-admin-app:v1.1.2` -2. Create a `.env` file. +1. Pull the (production) **/server** [Docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-app) from Docker Hub. + - Find the latest version tag from https://hub.docker.com/r/ciatphdev/firebase-users-app, i.e., `v1.1.5` + - `docker pull ciatphdev/firebase-users-app:v1.1.5` +2. Create a `.env` file. - Read [**Installation - server #3**](https://github.com/ciatph/firebase-users-admin#server) for more information. - Replace the variables accordingly in the `.env` file. Set `ALLOW_CORS=0` to allow `Same Origin` requests. Read [**Option #2 - Client and Server Bundled in (1) Image and Service**](https://github.com/ciatph/firebase-users-admin#option-2---client-and-server-bundled-in-1-image-and-service) for more information. ``` @@ -39,14 +40,14 @@ The server also serves a pre-built [`client`](https://github.com/ciatph/firebase docker run -it --rm \ --env-file .env -p 3001:3001 \ - ciatphdev/firebase-users-admin-app:v1.1.2 + ciatphdev/firebase-users-admin-app:v1.1.5 ``` -4. Run a script in the container to create the default `superadmin@gmail.com` account, if it does not yet exist in the Firestore database. +4. Run a script in the container to create the default `superadmin@gmail.com` account, if it does not yet exist in the Firestore database. `docker exec -it firebase-users-admin-app npm run seed` -5. Launch the server API documentation on +5. Launch the server API documentation on `http://localhost:3001/docs` 6. Launch the client website on `http://localhost:3001`. - - Login using the superadmin account create on step # 4. + - Login using the superadmin account create on step # 4. ``` username: superadmin@gmail.com password: 123456789 @@ -54,6 +55,32 @@ The server also serves a pre-built [`client`](https://github.com/ciatph/firebase - Test the API routes by creating new accounts, editing or deleting existing accounts. - The signed-in user's Firebase Auth token is available on the **Home** page (http://localhost:3001/) +### Pre-built Server Docker Image (Client + Server) Development + +Pre-built Docker images of the **server** and **client** for local development are also available on Docker Hub at: + +- **client**
+https://hub.docker.com/r/ciatphdev/firebase-users-client/tags + +- **server**
+https://hub.docker.com/r/ciatphdev/firebase-users-server/tags + +### Usage Options + +- Use with the docker-compose.dev.yml file (requires a `.env` file input parameter):
+`docker compose -f docker-compose.dev.yml pull` + +- Docker pull
+ ``` + docker pull ciatphdev/firebase-users-client:dev + docker pull ciatphdev/firebase-users-server:dev + ``` +- Docker run (requires a `.env` file input parameter):
+ ``` + docker run -it --rm --env-file .env -p 3000:3000 ciatphdev/firebase-users-client:dev + docker run -it --rm --env-file .env -p 3001:3001 ciatphdev/firebase-users-server:dev + ``` + ### References - [firebase-users-admin](https://github.com/ciatph/firebase-users-admin) (GitHub repository)