This commit is contained in:
parent
f5265a4e1d
commit
1d62a62f33
4 changed files with 70 additions and 10 deletions
35
README.md
35
README.md
|
@ -15,12 +15,6 @@ This app uses the I-Ching library app https://github.com/Velfi/i-ching.git.
|
||||||
Properties of the app can be configured in the file config.json. It is possible to configure the mail host and port.
|
Properties of the app can be configured in the file config.json. It is possible to configure the mail host and port.
|
||||||
It is also possible to configure the intervall of days between the sending of horoscopes and the time of sending. The default is to send one email every seven days at 8 am.-->
|
It is also possible to configure the intervall of days between the sending of horoscopes and the time of sending. The default is to send one email every seven days at 8 am.-->
|
||||||
|
|
||||||
## First Start
|
|
||||||
The app can be deployed by running:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ kubectl apply -f deployment.yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
This will start the deployment of the app in the pod, the service and an ingress for the HTTP frontend server and an ingress for the backend server.
|
This will start the deployment of the app in the pod, the service and an ingress for the HTTP frontend server and an ingress for the backend server.
|
||||||
When a pod with the app is initally started, one email will be sent to the configured receiver.
|
When a pod with the app is initally started, one email will be sent to the configured receiver.
|
||||||
|
@ -45,3 +39,32 @@ The Jest unit tests can be run with
|
||||||
$ npm test
|
$ npm test
|
||||||
```
|
```
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
## Running the App
|
||||||
|
|
||||||
|
### Locally
|
||||||
|
The app can be deployed locally by running:
|
||||||
|
The app can be deployed by running:
|
||||||
|
```bash
|
||||||
|
$ ./start-local.sh
|
||||||
|
```
|
||||||
|
Der HTTP-Server can be access in a browser with the address http://localhost:8080/.
|
||||||
|
|
||||||
|
### Locally with Docker
|
||||||
|
The app can be deployed by running:
|
||||||
|
```bash
|
||||||
|
$ docker run -e DEPLOY_MODE=docker -p 8080:8080 -p 8090:8090 --rm my-typescript-app
|
||||||
|
```
|
||||||
|
Der HTTP-Server can be access in a browser with the address http://localhost:8080/.
|
||||||
|
|
||||||
|
### In Kubernetes
|
||||||
|
|
||||||
|
The app can be deployed by running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ kubectl apply -f deployment.yaml
|
||||||
|
```
|
||||||
|
Der HTTP-Server can be access in a browser with the address https://192-168-197-2.c-one-infra.de/iching/
|
||||||
|
|
||||||
|
<!-- TODO: make address configurable again -->
|
|
@ -1,10 +1,11 @@
|
||||||
function handleClick(): void {
|
function handleClick(): void {
|
||||||
console.log("Der Button wurde geklickt!");
|
console.log("Der Button wurde geklickt!");
|
||||||
|
|
||||||
const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s';
|
//const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s';
|
||||||
|
const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' | 'local' }).DEPLOY_MODE ?? 'k8s';
|
||||||
|
|
||||||
const endpoint =
|
const endpoint =
|
||||||
deployMode === 'docker'
|
deployMode === 'docker' || deployMode === 'local'
|
||||||
? 'http://localhost:8090/iching/api/command'
|
? 'http://localhost:8090/iching/api/command'
|
||||||
: '/iching/api/command';
|
: '/iching/api/command';
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "broker.js",
|
"main": "broker.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --no-cache --force-exit"
|
"test": "jest --no-cache --force-exit",
|
||||||
|
"start:local": "tsc -p tsconfig.backend.json && tsc -p tsconfig.frontend.json && DEPLOY_MODE=local node dist/backend/server.js & npx http-server dist/frontend -p 8080 --cors --mime application/javascript=js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
35
start-local.sh
Executable file
35
start-local.sh
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
# build
|
||||||
|
#npm install
|
||||||
|
#npx tsc -p tsconfig.backend.json
|
||||||
|
#npx tsc -p tsconfig.frontend.json
|
||||||
|
|
||||||
|
#npm run start:local
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 1. Install dependencies
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# 2. Compile backend and frontend
|
||||||
|
npx tsc -p tsconfig.backend.json
|
||||||
|
npx tsc -p tsconfig.frontend.json
|
||||||
|
|
||||||
|
# 3. Ensure dist/frontend exists and copy index.html
|
||||||
|
mkdir -p dist/frontend
|
||||||
|
cp frontend/index.html dist/frontend/
|
||||||
|
|
||||||
|
# 4. Rename compiled frontend .js → .mjs
|
||||||
|
find dist/frontend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
||||||
|
|
||||||
|
# 5. Inject deploy mode
|
||||||
|
echo "window.DEPLOY_MODE = 'local';" > dist/frontend/deploy.js
|
||||||
|
|
||||||
|
# 6. Start backend
|
||||||
|
node dist/backend/server.js &
|
||||||
|
|
||||||
|
# 7. Start frontend
|
||||||
|
npx http-server dist/frontend -p 8080 --cors --mime application/javascript=js
|
Loading…
Reference in a new issue