Skip to content

Commit 72688b9

Browse files
committed
chore: Deploy server image with built client app to dockerhub, #56
1 parent cf58fcd commit 72688b9

4 files changed

Lines changed: 40 additions & 32 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ jobs:
118118
cp client/.env.example client/.env
119119
cp server/.env.example server/.env
120120
- name: Set release version number
121-
run: sed -i -e "s/latest/${{ github.event.release.tag_name }}/g" docker-compose.prod.yml
121+
run: sed -i -e "s/latest/${{ github.event.release.tag_name }}/g" docker-compose.app.yml
122122
- name: Build Images
123-
run: docker-compose -f docker-compose.prod.yml build
123+
run: docker-compose -f docker-compose.app.yml build
124124
- name: Push Images to Docker Hub
125-
run: docker-compose -f docker-compose.prod.yml push
125+
run: docker-compose -f docker-compose.app.yml push

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,15 @@ A basic web app client in the **/client** directory will show basic API usage an
66

77
## Content
88

9-
- [firebase-users-admin](#firebase-users-admin)
10-
- [Content](#content)
119
- [Requirements](#requirements)
12-
- [Core Libraries and Frameworks](#core-libraries-and-frameworks)
1310
- [Installation](#installation)
14-
- [server](#server)
15-
- [client](#client)
1611
- [Usage](#usage)
1712
- [Available Scripts - server](#available-scripts---server)
18-
- [`npm start`](#npm-start)
19-
- [`npm run dev`](#npm-run-dev)
20-
- [`npm run gen:docs`](#npm-run-gendocs)
21-
- [`npm run seed`](#npm-run-seed)
22-
- [`npm run copyclient`](#npm-run-copyclient)
2313
- [Installation and Usage Using Docker](#installation-and-usage-using-docker)
2414
- [Docker Dependencies](#docker-dependencies)
2515
- [Docker for Localhost Development](#docker-for-localhost-development)
2616
- [Docker for Production Deployment](#docker-for-production-deployment)
27-
- [Option #1 - Client and Server as (2) Separate Images and Services](#option-1---client-and-server-as-2-separate-images-and-services)
28-
- [Option #2 - Client and Server Bundled in (1) Image and Service](#option-2---client-and-server-bundled-in-1-image-and-service)
2917
- [Pre-built Server Docker Image](#pre-built-server-docker-image)
30-
- [Steps](#steps)
3118
- [References](#references)
3219

3320
## Requirements
@@ -210,7 +197,7 @@ The following docker-compose commands build small `client` and `server` images t
210197
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.
211198

212199
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).
213-
- > **INFO:** This method requires CORS checking dissabled, since the client and server will run on the same port (3001).
200+
- > **INFO:** This build method requires CORS checking dissabled, since the client and server will run on the same port (3001).
214201
> - Disable CORS by setting `ALLOW_CORS=0` in the **.env** file to avoid `Same Origin` errors.
215202
2. Build the client and server docker services for production deployment.
216203
- `docker-compose -f docker-compose-app.yml build`
@@ -227,34 +214,45 @@ The following docker-compose commands build a small `server` image targeted for
227214

228215
## Pre-built Server Docker Image
229216

230-
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.
217+
The `server` component of **firebase-users-admin** is available as a stand-alone docker image on Docker Hub with customizable environment variables (.env file).
218+
219+
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).
231220

232221
### Steps
233222

234-
1. Pull the (production) **/server** [docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-server) from Docker Hub.
235-
`docker pull ciatphdev/firebase-users-admin-server:v1.1.2`
223+
1. Pull the (production) **/server** [docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-app) from Docker Hub.
224+
`docker pull ciatphdev/firebase-users-admin-app:v1.1.2`
236225
2. Create a `.env` file.
237226
- Read [**Installation - server #3**](#server) for more information.
238-
- Replace the variables accordingly in the `.env` file.
227+
- 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.
239228
```
240229
ALLOWED_ORIGINS=http://localhost,http://localhost:3000,http://mywebsite.com,http://yourwebsite.com
241230
FIREBASE_SERVICE_ACC=YOUR-FIREBASE-PROJ-SERVICE-ACCOUNT-JSON-CREDENTIALS-ONE-LINER-NO-SPACES
242231
FIREBASE_PRIVATE_KEY=PRIVATE-KEY-FROM-FIREBASE-SERVICE-ACCOUNT-JSON-WITH-DOUBLE-QUOTES
243232
244-
ALLOW_CORS=1
233+
ALLOW_CORS=0
245234
ALLOW_AUTH=1
246235
```
247236
3. Run the image.
248237
```
249238
docker run -it --rm \
250239
--env-file .env \
251240
-p 3001:3001 \
252-
ciatphdev/firebase-users-admin-server:v1.1.2
241+
ciatphdev/firebase-users-admin-app:v1.1.2
253242
```
254243
4. Run a script in the container to create the default `[email protected]` account, if it does not yet exist in the Firestore database.
255-
`docker exec -it server-prod npm run seed`
244+
`docker exec -it firebase-users-admin-app npm run seed`
256245
5. Launch the server API documentation on
257246
`http://localhost:3001/docs`
247+
6. Launch the client website on `http://localhost:3001`.
248+
- Login using the superadmin account create on step # 4.
249+
```
250+
251+
password: 123456789
252+
```
253+
- Test the API routes by creating new accounts, editing or deleting existing accounts.
254+
- The signed-in user's Firebase Auth token is available on the **Home** page (http://localhost:3001/)
255+
258256
259257
260258
## References

client/src/.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
quotes: ['error', 'single'],
3030
semi: ['error', 'never'],
3131
'no-unused-vars': 'off',
32-
'no-undef': 'off',
33-
'no-console': 2
32+
'no-undef': 'off'
33+
// 'no-console': 2
3434
}
3535
}

server/src/utils/templates/header.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,40 @@ password: 123456789
1919

2020
firebase-users-admin's server component, hosting all the listed endpoints below is available as a stand-alone [docker image](https://hub.docker.com/r/ciatphdev/firebase-users-admin-server) on Docker Hub with customizable environment variables (.env file).
2121

22-
1. Pull the (production) **/server** docker image from Docker Hub.
23-
`docker pull ciatphdev/firebase-users-admin-server:v1.1.2`
22+
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).
23+
24+
1. Pull the (production) **/server** [docker image](https://hub.docker.com/repository/docker/ciatphdev/firebase-users-admin-server) from Docker Hub.
25+
`docker pull ciatphdev/firebase-users-admin-app:v1.1.2`
2426
2. Create a `.env` file.
2527
- Read [**Installation - server #3**](https://github.com/ciatph/firebase-users-admin#server) for more information.
26-
- Replace the variables accordingly in the `.env` file.
28+
- 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.
2729
```
2830
ALLOWED_ORIGINS=http://localhost,http://localhost:3000,http://mywebsite.com,http://yourwebsite.com
2931
FIREBASE_SERVICE_ACC=YOUR-FIREBASE-PROJ-SERVICE-ACCOUNT-JSON-CREDENTIALS-ONE-LINER-NO-SPACES
3032
FIREBASE_PRIVATE_KEY=PRIVATE-KEY-FROM-FIREBASE-SERVICE-ACCOUNT-JSON-WITH-DOUBLE-QUOTES
3133
32-
ALLOW_CORS=1
34+
ALLOW_CORS=0
3335
ALLOW_AUTH=1
3436
```
3537
3. Run the image.
3638
```
3739
docker run -it --rm \
3840
--env-file .env
3941
-p 3001:3001 \
40-
ciatphdev/firebase-users-admin-server:v1.1.2
42+
ciatphdev/firebase-users-admin-app:v1.1.2
4143
```
4244
4. Run a script in the container to create the default `[email protected]` account, if it does not yet exist in the Firestore database.
43-
`docker exec -it server-prod npm run seed`
45+
`docker exec -it firebase-users-admin-app npm run seed`
4446
5. Launch the server API documentation on
4547
`http://localhost:3001/docs`
48+
6. Launch the client website on `http://localhost:3001`.
49+
- Login using the superadmin account create on step # 4.
50+
```
51+
52+
password: 123456789
53+
```
54+
- Test the API routes by creating new accounts, editing or deleting existing accounts.
55+
- The signed-in user's Firebase Auth token is available on the **Home** page (http://localhost:3001/)
4656
4757
### References
4858

0 commit comments

Comments
 (0)