Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 5c883f9

Browse files
authored
Merge pull request #11 from topcoder-platform/dev
local conf files for deployment, docker node ver, handle auth redirects
2 parents bb9ce1f + b200c68 commit 5c883f9

File tree

4 files changed

+287
-2
lines changed

4 files changed

+287
-2
lines changed

README.md

+277
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,280 @@ The URL for the React app started this way would look like:
294294
There is no universal approach to run any React app as child app in Single SPA. This is because unlike Angular application which always use Angular CLI, each React application has it's own Webpack config. And to be able to run React app as a child microapp we need the Webpack to be configured in a certain way.
295295
296296
- Here is Official Video form the creator of Single Spa on [How To Convert a create-react-app (CRA) project to single-spa](https://www.youtube.com/watch?v=W8oaySHuj3Y&list=PLLUD8RtHvsAOhtHnyGx57EYXoaNsxGrTU)
297+
298+
299+
300+
301+
302+
### Checkout 4 repos and apply patches:
303+
- git clone https://github.com/topcoder-platform/micro-frontends-frame.git
304+
- git clone https://github.com/topcoder-platform/micro-frontends-navbar-app.git
305+
- git clone https://github.com/topcoder-platform/micro-frontends-react-app.git
306+
- git clone https://github.com/topcoder-platform/micro-frontends-angular-app.git
307+
and create a folder (ex: 'auth0-local-login'), and save the following file: 'https://accounts-auth0.topcoder-dev.com/setupAuth0WithRedirect.js' into that folder. After 'setupAuth0WithRedirect.js' file was saved, create an empty 'index.html' file with the following content:
308+
```
309+
<!DOCTYPE html>
310+
<html>
311+
<head>
312+
<title>Auth0</title>
313+
<meta charset="utf-8" />
314+
<script language="javascript" type="text/javascript" src="./setupAuth0WithRedirect.js"></script>
315+
</head>
316+
<body>
317+
Loaded...redirecting to auth0.(see browser console log)
318+
<script>
319+
window.onload = authSetup;
320+
</script>
321+
<a href="?retUrl=http://localhost:3000" >Login</a>
322+
</body>
323+
</html>
324+
```
325+
### Local deployment:
326+
(1). root-config:
327+
open Terminal #1
328+
change the current dir to the root-config folder and apply patch:
329+
- cd micro-frontends-frame
330+
- git apply ../micro-frontends-frame.diff --ignore-whitespace --whitespace=nowarn
331+
install dependencies:
332+
- npm install
333+
build and run the app:
334+
- APPMODE=development APPENV=local npm run build
335+
- APPMODE=development APPENV=local npm run local-server
336+
(2). navbar-app:
337+
open Terminal #2
338+
change the current dir to the navbar-app folder and apply patch:
339+
- cd micro-frontends-navbar-app
340+
- git apply ../micro-frontends-navbar-app.diff --ignore-whitespace --whitespace=nowarn
341+
there is a config file: '{navbar-app-repo}/config/development.js'. To login locally, change 'ACCOUNTS_APP_CONNECTOR', and 'AUTH' to point to the server that will be served in folder 'auth0-local-login' which was setup in the previous step.
342+
```
343+
URL: {
344+
ACCOUNTS_APP_CONNECTOR: "http://localhost:5000",
345+
AUTH: "http://localhost:5000"
346+
...
347+
}
348+
```
349+
install dependencies:
350+
- npm install
351+
build and run the app (choose 1 out of 3 ways listed bellow):
352+
for development build with hot-reload:
353+
- npm run dev
354+
or
355+
for development build with static server:
356+
- APPMODE=development npm run build
357+
- npm start
358+
or
359+
for production build with static server:
360+
- npm run build
361+
- npm start
362+
NOTE:
363+
Default backend environment is always the dev environment. To switch to production environment, add APPENV=production before the command, ex:
364+
- APPENV=production npm run dev
365+
or
366+
- APPENV=production npm run build
367+
- npm start
368+
(3). react-app:
369+
open Terminal #3
370+
change the current dir to the react-app folder and apply patch:
371+
- cd micro-frontends-react-app
372+
- git apply ../micro-frontends-react-app.diff --ignore-whitespace --whitespace=nowarn
373+
install dependencies:
374+
- npm install
375+
build and run the app:
376+
- npm run dev
377+
(4). angular-app:
378+
open Terminal #4
379+
change the current dir to the angular-app folder and apply patch:
380+
- cd micro-frontends-angular-app
381+
- git apply ../micro-frontends-angular-app.diff --ignore-whitespace --whitespace=nowarn
382+
install dependencies:
383+
- npm install
384+
build and run the app:
385+
- npm run dev
386+
(5). auth0 login in local mode
387+
open Terminal #5
388+
change the current dir to the 'auth0-local-login' folder and serve with the index.htm file
389+
- cd auth0-local-login
390+
- npx http-server . -p 5000
391+
The app can be open at the browser url: 'http://localhost:5000' (this page will redirect to the actual page: 'http://localhost:3000')
392+
393+
## Local deployment - handle auth redirects
394+
395+
### Checkout 4 repos and apply patches:
396+
397+
- git clone https://github.com/topcoder-platform/micro-frontends-frame.git
398+
399+
- git clone https://github.com/topcoder-platform/micro-frontends-navbar-app.git
400+
401+
- git clone https://github.com/topcoder-platform/micro-frontends-react-app.git
402+
403+
- git clone https://github.com/topcoder-platform/micro-frontends-angular-app.git
404+
405+
and create a folder (ex: 'auth0-local-login'), and save the following file: 'https://accounts-auth0.topcoder-dev.com/setupAuth0WithRedirect.js' into that folder. After 'setupAuth0WithRedirect.js' file was saved, create an empty 'index.html' file with the following content:
406+
407+
```
408+
409+
<!DOCTYPE html>
410+
411+
<html>
412+
413+
<head>
414+
415+
<title>Auth0</title>
416+
417+
<meta charset="utf-8" />
418+
419+
<script language="javascript" type="text/javascript" src="./setupAuth0WithRedirect.js"></script>
420+
421+
</head>
422+
423+
<body>
424+
425+
Loaded...redirecting to auth0.(see browser console log)
426+
427+
<script>
428+
429+
window.onload = authSetup;
430+
431+
</script>
432+
433+
<a href="?retUrl=http://localhost:3000" >Login</a>
434+
435+
</body>
436+
437+
</html>
438+
439+
```
440+
441+
### Local deployment:
442+
443+
(1). root-config:
444+
445+
open Terminal #1
446+
447+
change the current dir to the root-config folder and apply patch:
448+
449+
- cd micro-frontends-frame
450+
451+
- git apply ../micro-frontends-frame.diff --ignore-whitespace --whitespace=nowarn
452+
453+
install dependencies:
454+
455+
- npm install
456+
457+
build and run the app:
458+
459+
- APPMODE=development APPENV=local npm run build
460+
461+
- APPMODE=development APPENV=local npm run local-server
462+
463+
(2). navbar-app:
464+
465+
open Terminal #2
466+
467+
change the current dir to the navbar-app folder and apply patch:
468+
469+
- cd micro-frontends-navbar-app
470+
471+
- git apply ../micro-frontends-navbar-app.diff --ignore-whitespace --whitespace=nowarn
472+
473+
there is a config file: '{navbar-app-repo}/config/development.js'. To login locally, change 'ACCOUNTS_APP_CONNECTOR', and 'AUTH' to point to the server that will be served in folder 'auth0-local-login' which was setup in the previous step.
474+
475+
```
476+
477+
URL: {
478+
479+
ACCOUNTS_APP_CONNECTOR: "http://localhost:5000",
480+
481+
AUTH: "http://localhost:5000"
482+
483+
...
484+
485+
}
486+
487+
```
488+
489+
install dependencies:
490+
491+
- npm install
492+
493+
build and run the app (choose 1 out of 3 ways listed bellow):
494+
495+
for development build with hot-reload:
496+
497+
- npm run dev
498+
499+
or
500+
501+
for development build with static server:
502+
503+
- APPMODE=development npm run build
504+
505+
- npm start
506+
507+
or
508+
509+
for production build with static server:
510+
511+
- npm run build
512+
513+
- npm start
514+
515+
NOTE:
516+
517+
Default backend environment is always the dev environment. To switch to production environment, add APPENV=production before the command, ex:
518+
519+
- APPENV=production npm run dev
520+
521+
or
522+
523+
- APPENV=production npm run build
524+
525+
- npm start
526+
527+
(3). react-app:
528+
529+
open Terminal #3
530+
531+
change the current dir to the react-app folder and apply patch:
532+
533+
- cd micro-frontends-react-app
534+
535+
- git apply ../micro-frontends-react-app.diff --ignore-whitespace --whitespace=nowarn
536+
537+
install dependencies:
538+
539+
- npm install
540+
541+
build and run the app:
542+
543+
- npm run dev
544+
545+
(4). angular-app:
546+
547+
open Terminal #4
548+
549+
change the current dir to the angular-app folder and apply patch:
550+
551+
- cd micro-frontends-angular-app
552+
553+
- git apply ../micro-frontends-angular-app.diff --ignore-whitespace --whitespace=nowarn
554+
555+
install dependencies:
556+
557+
- npm install
558+
559+
build and run the app:
560+
561+
- npm run dev
562+
563+
(5). auth0 login in local mode
564+
565+
open Terminal #5
566+
567+
change the current dir to the 'auth0-local-login' folder and serve with the index.htm file
568+
569+
- cd auth0-local-login
570+
571+
- npx http-server . -p 5000
572+
573+
The app can be open at the browser url: 'http://localhost:5000' (this page will redirect to the actual page: 'http://localhost:3000')

config/micro-frontends-config-local.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"@topcoder/micro-frontends-angular-app": "http://local.topcoder-dev.com:4200/angular/main.js",
66
"@topcoder/micro-frontends-teams": "http://local.topcoder-dev.com:8501/taas-app/topcoder-micro-frontends-teams.js",
77
"@topcoder/micro-frontends-task-marketplace-app": "http://local.topcoder-dev.com:8502/tasks/topcoder-micro-frontends-task-marketplace-app.js",
8-
"@topcoder/micro-frontends-earn-app": "http://local.topcoder-dev.com:8008/earn/topcoder-micro-frontends-earn-app.js"
8+
"@topcoder/micro-frontends-earn-app": "http://local.topcoder-dev.com:8008/earn/topcoder-micro-frontends-earn-app.js",
9+
"@topcoder/micro-frontends-submission-review-app": "http://local.topcoder-dev.com:8503/submissionreview/topcoder-micro-frontends-submission-review-app.js",
10+
"@topcoder/micro-frontends-model-app": "http://local.topcoder-dev.com:8504/model/topcoder-micro-frontends-model-app.js"
911
}
1012
}

config/micro-frontends-routes-local.txt

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
<route path="earn">
1414
<application name="@topcoder/micro-frontends-earn-app"></application>
1515
</route>
16+
<route path="submissionreview">
17+
<application name="@topcoder/micro-frontends-submission-review-app"></application>
18+
</route>
19+
<route path="model">
20+
<application name="@topcoder/micro-frontends-model-app"></application>
21+
</route>
1622
<route path="unauthorized">
1723
<div style="text-align: center; padding-top: 200px; font-size: 32px;">
1824
You are unauthorized

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use the base image with Node.js
2-
FROM node:latest
2+
FROM node:10.22.1
33

44
ARG APPMODE
55
ARG APPENV

0 commit comments

Comments
 (0)