From f70d3f268b78bacdb2536685dc8c3f53b8cf1f6f Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 15:53:34 +0800 Subject: [PATCH 1/5] feat: use firebase config from env file, #71 --- README.md | 112 ++++++++++-------- client/.env.example | 9 +- .../common/navigation/userbutton.js | 2 +- .../firebase => config}/firebase.config.js | 14 +-- client/src/containers/login/index.js | 2 +- client/src/containers/login/withauth.js | 2 +- client/src/utils/service/service.js | 2 +- 7 files changed, 84 insertions(+), 59 deletions(-) rename client/src/{utils/firebase => config}/firebase.config.js (58%) diff --git a/README.md b/README.md index ebc80f5..27a188e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ A basic web app client in the **/client** directory will show basic API usage an 2. NodeJS v14.18.3 or higher 3. Firebase Project [[link]](https://firebase.google.com/) - Pricing Plan: Spark plan or higher - - with the **Email/Password** Provider enabled in the Firebase Console's + - with the **Email/Password** Provider enabled in the Firebase Console's **Authentication** -> **Sign-in method** -> **Sign-in providers** options. - Service account credentials JSON file @@ -38,14 +38,14 @@ A basic web app client in the **/client** directory will show basic API usage an ### server -1. Clone this repository. +1. Clone this repository.
`git clone https://github.com/ciatph/firebase-users-admin.git` -2. Install dependencies. +2. Install dependencies. ``` cd server npm install ``` -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: +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: | Variable Name | Description | | --- | --- | @@ -63,34 +63,44 @@ A basic web app client in the **/client** directory will show basic API usage an cd client npm install ``` -2. Replace the `/client/utils/firebase/firebase.config.js` file with your own Firebase project's web SDK setup configuration file. - - You can find this file in a Firebase project's +2. Replace the `/client/config/firebase.config.js` file with your own Firebase project's web SDK setup configuration file. + - You can find this file in a Firebase project's **Project Settings** -> **General** -> **Web apps** (Add an app if needed) -> **SDK setup and configuration** - The `firebase.config.js` settings must match with the `FIREBASE_SERVICE_ACC` environment variable defined on **server - step # 3.** -3. Create a `/client/.env` file from the `/client/.env.example` file. Replace the `REACT_APP_BASE_URL` variable with an appropriate value. +3. Create a `/client/.env` file from the `/client/.env.example` file. + - Replace the `REACT_APP_BASE_URL` variable with an appropriate value. + - Replace the `REACT_APP_FIREBASE_*` set of variables with your own Firebase project configuration that matches the **server** variables: `FIREBASE_SERVICE_ACC` and `FIREBASE_PRIVATE_KEY`. These variables, using default values from this repository's Firebase project will not work with your **server** Firebase variables. | Variable Name | Description | | --- | --- | |REACT_APP_BASE_URL|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.| -4. Run the app in development mode. + | REACT_APP_FIREBASE_API_KEY | Firebase web API key from the Firebase Project Settings configuration file. | + | REACT_APP_FIREBASE_AUTHDOMAIN | Firebase web auth domain key from the Firebase Project Settings configuration file. | + | REACT_APP_FIREBASE_PROJECT_ID | Firebase web project ID from the Firebase Project Settings configuration file. | + | REACT_APP_FIREBASE_STORAGE_BUCKET | Firebase web storage bucket key from the Firebase Project Settings configuration file. | + | REACT_APP_FIREBASE_MESSAGING_SENDER_ID | Firebase web messaging sender ID from the Firebase Project Settings configuration file. | + | REACT_APP_FIREBASE_APP_ID | Firebase web web app key from the Firebase Project Settings configuration file. | + | REACT_APP_FIREBASE_MEASUREMENT_ID | Firebase web measurement ID from the Firebase Project Settings configuration file. | + +4. Run the app in development mode. `npm start` -5. Launch the client app in: +5. Launch the client app in: `http://localhost:3000` ## Usage 1. Navigate to the `/server` directory. -2. Create a default Firebase Auth user. +2. Create a default Firebase Auth user. `npm run seed` -3. Generate the API documentation. +3. Generate the API documentation. `npm run gen:docs` -4. Run the app: +4. Run the app: - (development mode) `npm run dev` - (production mode) `npm start` -5. Read the API documentation and usage examples guide of available CRUD API endpoints on: +5. Read the API documentation and usage examples guide of available CRUD API endpoints on: `http://localhost:3001/docs` -6. Try to log-in to the `/client` app using the default superadmin seeded user from step no. 2: +6. Try to log-in to the `/client` app using the default superadmin seeded user from step no. 2: ``` username: superadmin@gmail.com password: 123456789 @@ -117,7 +127,7 @@ Builds the API documentation. The static website documentation files are put in ### `npm run seed` -Creates an initial **superadmin** Firebase Authentication user with the credentials: +Creates an initial **superadmin** Firebase Authentication user with the credentials: ``` email: superadmin@gmail.com @@ -130,7 +140,7 @@ account_level: 1 Copies the built `/client` website from `/client/build` to the server's root directory. -- It requires to build the client app first, after following its set-up [instructions](#client): +- It requires to build the client app first, after following its set-up [instructions](#client): ``` cd client npm run build @@ -153,23 +163,22 @@ The following dependencies are used to build and run the image. Please feel feel ### Docker for Localhost Development 1. Set-up the environment variables and firebase configuration file for the **/client** app. - - Create (your own) `firebase.config.js` file under `/client/utils/firebase/firebase.config.js` as advised on [**Installation - client # 2**](#client). - Create the `.env` file under the **/client** directory as advised on [**Installation - client # 3**](#client). 2. Set-up the environment variables for the **/server** app. - Create the `.env` file under the **/server** directory as advised on [**Installation - server # 3**](#server). -3. Build the client and server docker services for localhost development. +3. Build the client and server docker services for localhost development. - `docker-compose -f docker-compose-dev.yml build` - > **INFO:** Building the images for localhost development takes a while, around ~7min+. -4. Create and start the client and server containers. +4. Create and start the client and server containers. `docker-compose -f docker-compose-dev.yml up` -5. Run a script in the container to create the default `superadmin@gmail.com` account, if it does not yet exist in the Firestore database. +5. 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 server-prod npm run seed` -6. Launch the dockerized (dev) client app on +6. Launch the dockerized (dev) client app on `http://localhost:3000` -7. Launch the dockerized (dev) server app's API documentation on +7. Launch the dockerized (dev) server app's API documentation on `http://localhost:3001/docs` 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. -9. Stop and remove containers, networks, images and volumes: +9. Stop and remove containers, networks, images and volumes: `docker-compose -f docker-compose-dev.yml down` ### Docker for Production Deployment @@ -179,50 +188,55 @@ The following dependencies are used to build and run the image. Please feel feel The following docker-compose commands build small `client` and `server` images targeted for creating optimized dockerized apps running on self-managed production servers. An **Nginx** service serves the frontend `client` on port `3000`. The `server`, running on a separate **Nodejs (pm2)** service, is also served by the client's Nginx service in a reverse proxy on port `3001`. Hot reload is not available when editing source codes from `/client/src` or `/server/src`. 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). -2. Build the client and server docker services for production deployment. +2. Build the client and server docker services for production deployment. - `docker-compose -f docker-compose-prod.yml build` -3. Create and start the containers. +3. Create and start the containers. - `docker-compose -f docker-compose-prod.yml up` -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 server-prod npm run seed` -5. Launch the dockerized (prod) client app on +5. Launch the dockerized (prod) client app on `http://localhost:3000` -6. Launch the dockerized (prod) server app's API documentation on +6. Launch the dockerized (prod) server app's API documentation on `http://localhost:3001/docs` -7. Stop and remove containers, networks, images and volumes: +7. Stop and remove containers, networks, images and volumes: - `docker-compose -f docker-compose-prod.yml down` - + #### Option #2 - Client and Server Bundled in (1) Image and Service -The following docker-compose commands build a small `server` image targeted for creating an optimized dockerized Express app running on self-managed production servers. The frontend `client` is served in an a static directory using the Express static middleware. +The following docker-compose commands build a small `server` image targeted for creating an optimized dockerized Express app running on self-managed production servers. The frontend `client` is served in an a static directory using the Express static middleware. 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). - - > **INFO:** This build method requires CORS checking dissabled, since the client and server will run on the same port (3001). - > - Disable CORS by setting `ALLOW_CORS=0` in the **.env** file to avoid `Same Origin` errors. -2. Build the client and server docker services for production deployment. + - > **INFO:** This build method requires CORS checking dissabled, since the client and server will run on the same port (3001). + > - Disable CORS by setting `ALLOW_CORS=0` in the **.env** file to avoid `Same Origin` errors. +2. Build the client and server docker services for production deployment. - `docker-compose -f docker-compose-app.yml build` -3. Create and start the containers. +3. Create and start the containers. - `docker-compose -f docker-compose-app.yml up` -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 dockerized (prod) client + server app on +5. Launch the dockerized (prod) client + server app on `http://localhost:3000` -6. Launch the dockerized (prod) client + server app API documentation on +6. Launch the dockerized (prod) client + server app API documentation on `http://localhost:3001/docs` -7. Stop and remove containers, networks, images and volumes: +7. Stop and remove containers, networks, images and volumes: - `docker-compose -f docker-compose-app.yml down` -## Pre-built Server Docker Image +## Pre-built Server Docker Image App The `server` component of **firebase-users-admin** is available as a stand-alone docker image on Docker Hub with customizable environment variables (.env file). The server also serves the pre-built `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**](#option-2---client-and-server-bundled-in-1-image-and-service). +> [!WARNING] +> While the pre-built Docker image runs both **client** and **server** apps, the **client** only works for this code repository at **ciatph/firebase-users-admin**, since it uses the repository's specific Firebase config settings during **client** (React) build. + ### Steps -1. Pull the (production) **/server** [docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-app) 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` + - **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. ``` @@ -240,12 +254,12 @@ The server also serves the pre-built `client` website from a static directory us -p 3001:3001 \ ciatphdev/firebase-users-admin-app:v1.1.2 ``` -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 @@ -253,11 +267,15 @@ The server also serves the pre-built `client` website from a static directory us - 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** are also available on Docker Hub at:
+https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-app ## References [[1]](https://docs.docker.com/compose/reference/) - docker compose commands -@ciatph +@ciatph 20220406 diff --git a/client/.env.example b/client/.env.example index d2ed423..4b5d85b 100644 --- a/client/.env.example +++ b/client/.env.example @@ -1 +1,8 @@ -REACT_APP_BASE_URL=http://localhost:3001/api \ No newline at end of file +REACT_APP_BASE_URL=http://localhost:3001/api +REACT_APP_FIREBASE_API_KEY=AIzaSyB1SivNCSCPXFV4v4FhE-Ll2av8nHEWr-8 +REACT_APP_FIREBASE_AUTHDOMAIN=users-admin-firebase.firebaseapp.com +REACT_APP_FIREBASE_PROJECT_ID=users-admin-firebase +REACT_APP_FIREBASE_STORAGE_BUCKET=users-admin-firebase.appspot.com +REACT_APP_FIREBASE_MESSAGING_SENDER_ID=761515421472 +REACT_APP_FIREBASE_APP_ID=1:761515421472:web:d7c737ba274515297f3145 +REACT_APP_FIREBASE_MEASUREMENT_ID=G-ZCWY6YX0P0 \ No newline at end of file diff --git a/client/src/components/common/navigation/userbutton.js b/client/src/components/common/navigation/userbutton.js index 3c4b075..93ad01f 100644 --- a/client/src/components/common/navigation/userbutton.js +++ b/client/src/components/common/navigation/userbutton.js @@ -1,5 +1,5 @@ import { Link } from 'react-router-dom' -import { auth, signOut } from '../../../utils/firebase/firebase.config' +import { auth, signOut } from '../../../config/firebase.config' function UserButton (hasUser) { const logout = async () => { diff --git a/client/src/utils/firebase/firebase.config.js b/client/src/config/firebase.config.js similarity index 58% rename from client/src/utils/firebase/firebase.config.js rename to client/src/config/firebase.config.js index 03c83d9..40ebee3 100644 --- a/client/src/utils/firebase/firebase.config.js +++ b/client/src/config/firebase.config.js @@ -7,13 +7,13 @@ import { getAuth, signOut, signInWithEmailAndPassword } from 'firebase/auth' // Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { - apiKey: 'AIzaSyB1SivNCSCPXFV4v4FhE-Ll2av8nHEWr-8', - authDomain: 'users-admin-firebase.firebaseapp.com', - projectId: 'users-admin-firebase', - storageBucket: 'users-admin-firebase.appspot.com', - messagingSenderId: '761515421472', - appId: '1:761515421472:web:d7c737ba274515297f3145', - measurementId: 'G-ZCWY6YX0P0' + apiKey: process.env.REACT_APP_FIREBASE_API_KEY, + authDomain: process.env.REACT_APP_FIREBASE_AUTHDOMAIN, + projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID, + storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET, + messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID, + appId: process.env.REACT_APP_FIREBASE_APP_ID, + measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID } // Initialize Firebase diff --git a/client/src/containers/login/index.js b/client/src/containers/login/index.js index 89e18dc..935e27f 100644 --- a/client/src/containers/login/index.js +++ b/client/src/containers/login/index.js @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' import PropTypes from 'prop-types' -import { auth, signInWithEmailAndPassword } from '../../utils/firebase/firebase.config' +import { auth, signInWithEmailAndPassword } from '../../config/firebase.config' import Login from '../../components/common/form' import AlertMessage from '../../components/common/alert_message' diff --git a/client/src/containers/login/withauth.js b/client/src/containers/login/withauth.js index f0cbbaf..58a8138 100644 --- a/client/src/containers/login/withauth.js +++ b/client/src/containers/login/withauth.js @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { auth, signOut } from '../../utils/firebase/firebase.config' +import { auth, signOut } from '../../config/firebase.config' const WithAuth = (Component) => { function AuthAwareComponent (props) { diff --git a/client/src/utils/service/service.js b/client/src/utils/service/service.js index cda2698..f051cba 100644 --- a/client/src/utils/service/service.js +++ b/client/src/utils/service/service.js @@ -1,5 +1,5 @@ import axios from 'axios' -import { auth } from '../firebase/firebase.config' +import { auth } from '../../config/firebase.config' export default class Service { constructor () { From cd9a32c6cf458907f4e813be26dc71fd261c0314 Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 15:54:37 +0800 Subject: [PATCH 2/5] chore: rename docker images --- docker-compose.app.yml | 14 +++++++------- docker-compose.dev.yml | 13 ++++++------- docker-compose.prod.yml | 13 ++++++------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/docker-compose.app.yml b/docker-compose.app.yml index 947d22c..786e38f 100644 --- a/docker-compose.app.yml +++ b/docker-compose.app.yml @@ -2,12 +2,12 @@ # - Express backend that restarts itself on errors running on pm2 # - Create React App (CRA) client served from a static directory (using express.static() middleware) # Requirements: Disable CORS to allow Same Origin headers on client and server APIs -version: "3" + services: # Built Create React App (CRA) website running on nginx - firebase-users-admin-app: - container_name: firebase-users-admin-app - image: ciatphdev/firebase-users-admin-app:latest + firebase-users-app: + container_name: firebase-users-app + image: ciatphdev/firebase-users-app:latest restart: always env_file: - ./server/.env @@ -17,11 +17,11 @@ services: dockerfile: Dockerfile.app target: production networks: - - firebase-users-admin-app + - firebase-users-app ports: - "3001:3001" networks: - firebase-users-admin-app: - name: firebase-users-admin-app + firebase-users-app: + name: firebase-users-app external: false diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 62aaf81..e2c60f5 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,9 +1,8 @@ -version: "3" services: # Create React App (CRA) running on development mode client-dev: container_name: client-dev - image: ciatphdev/firebase-users-admin-client:dev + image: ciatphdev/firebase-users-client:dev env_file: - ./client/.env build: @@ -11,7 +10,7 @@ services: dockerfile: Dockerfile target: development networks: - - firebase-users-admin-dev + - firebase-users-dev volumes: - ./client/public:/opt/client/public - ./client/src:/opt/client/src @@ -21,7 +20,7 @@ services: # Express app running in development mode with auto reload using nodemon server-dev: container_name: server-dev - image: ciatphdev/firebase-users-admin-server:dev + image: ciatphdev/firebase-users-server:dev env_file: - ./server/.env build: @@ -29,13 +28,13 @@ services: dockerfile: Dockerfile target: development networks: - - firebase-users-admin-dev + - firebase-users-dev volumes: - ./server/src:/opt/server/src ports: - "3001:3001" networks: - firebase-users-admin-dev: - name: firebase-users-admin-dev + firebase-users-dev: + name: firebase-users-dev external: false diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 9c33e5d..6283954 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,11 +1,10 @@ # Builds (2) separate images for the client and server -version: "3" services: # Build Create React App (CRA) website running on nginx container client-prod: container_name: client-prod - image: ciatphdev/firebase-users-admin-client:latest + image: ciatphdev/firebase-users-client:latest restart: always env_file: - ./client/.env @@ -14,14 +13,14 @@ services: dockerfile: Dockerfile target: production networks: - - firebase-users-admin + - firebase-users ports: - "3000:3000" # Express app (backend only) that restarts itself on errors using pm2 server-prod: container_name: server-prod - image: ciatphdev/firebase-users-admin-server:latest + image: ciatphdev/firebase-users-server:latest restart: always env_file: - ./server/.env @@ -30,11 +29,11 @@ services: dockerfile: Dockerfile target: production networks: - - firebase-users-admin + - firebase-users ports: - "3001:3001" networks: - firebase-users-admin: - name: firebase-users-admin + firebase-users: + name: firebase-users external: false From 72ed2675a0f68410ff542799da80e548f5eff9a6 Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 16:03:06 +0800 Subject: [PATCH 3/5] feat: deploy development docker images to docker hub --- .github/workflows/release.yml | 26 +++++++++++++++++++++++++- README.md | 25 +++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8ea42a..2b2955a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,8 +108,9 @@ jobs: - run: git push heroku HEAD:refs/heads/master - run: rm -r -f .netrc + # Push the complete "app" Docker image docker-build-push: - name: Deploy to Docker Hub + name: Deploy App to Docker Hub runs-on: ubuntu-latest steps: - name: Login to Docker Hub @@ -133,3 +134,26 @@ jobs: run: docker compose -f docker-compose.app.yml build - name: Push Images to Docker Hub run: docker compose -f docker-compose.app.yml push + + # Push the development (client/server) Docker images + docker-build-push-dev: + name: Deploy Development to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Checkout the repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.tag_name }} + - name: Create temporary env variables + run: | + cp client/.env.example client/.env + cp server/.env.example server/.env + - name: Build Images + run: docker compose -f docker-compose.dev.yml build + - name: Push Images to Docker Hub + run: docker compose -f docker-compose.dev.yml push diff --git a/README.md b/README.md index 27a188e..c737246 100644 --- a/README.md +++ b/README.md @@ -269,8 +269,29 @@ The server also serves the pre-built `client` website from a static directory us ## Pre-built Server Docker Image (Client + Server) Development -Pre-built Docker images of the **server** and **client** are also available on Docker Hub at:
-https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-app +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 inside the client and server folders):
+`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 inside the client and server folders):
+ ``` + 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 From 0c9a29d6c7e23ba607ea1b7cd15e8ba849a2edf5 Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 16:08:35 +0800 Subject: [PATCH 4/5] chore: deploy on create of new release from master branch --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b2955a..655356f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,7 @@ on: jobs: lint-client: name: Lint and Build client + if: github.event.release.target_commitish == 'master' runs-on: ubuntu-latest env: REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} @@ -46,6 +47,7 @@ jobs: lint-server: name: Lint Server + if: github.event.release.target_commitish == 'master' runs-on: ubuntu-latest strategy: matrix: @@ -67,6 +69,7 @@ jobs: deploy-client: name: Deploy Client to Firebase Hosting + if: github.event.release.target_commitish == 'master' needs: lint-client runs-on: ubuntu-latest steps: @@ -111,6 +114,7 @@ jobs: # Push the complete "app" Docker image docker-build-push: name: Deploy App to Docker Hub + if: github.event.release.target_commitish == 'master' runs-on: ubuntu-latest steps: - name: Login to Docker Hub @@ -138,6 +142,7 @@ jobs: # Push the development (client/server) Docker images docker-build-push-dev: name: Deploy Development to Docker Hub + if: github.event.release.target_commitish == 'master' runs-on: ubuntu-latest steps: - name: Login to Docker Hub From 1bc5a8cd5bc8f723f86595376716d15abb9bc553 Mon Sep 17 00:00:00 2001 From: ciatph Date: Sun, 29 Sep 2024 16:12:22 +0800 Subject: [PATCH 5/5] chore: update toc --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c737246..99cfe16 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ A basic web app client in the **/client** directory will show basic API usage an - [Docker Dependencies](#docker-dependencies) - [Docker for Localhost Development](#docker-for-localhost-development) - [Docker for Production Deployment](#docker-for-production-deployment) -- [Pre-built Server Docker Image](#pre-built-server-docker-image) +- [Pre-built Server Docker Image](#pre-built-server-docker-image-app) +- [Pre-built Server Docker Image](#pre-built-server-docker-image-client--server-development) - [References](#references) ## Requirements