add http-server part 8.3.1
This commit is contained in:
parent
ff7bf73e93
commit
174ab60173
9 changed files with 32 additions and 208 deletions
|
@ -7,7 +7,7 @@ const port = 8090;
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
app.post('/command', (req, res) => {
|
app.post('/api/command', (req, res) => {
|
||||||
executeCommand();
|
executeCommand();
|
||||||
res.status(200).send('Command executed\n');
|
res.status(200).send('Command executed\n');
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,6 +11,7 @@ spec:
|
||||||
- host: 192-168-197-2.c-one-infra.de
|
- host: 192-168-197-2.c-one-infra.de
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
|
# API → kein Rewrite
|
||||||
- path: /iching/api(/|$)(.*)
|
- path: /iching/api(/|$)(.*)
|
||||||
pathType: ImplementationSpecific
|
pathType: ImplementationSpecific
|
||||||
backend:
|
backend:
|
||||||
|
@ -18,6 +19,8 @@ spec:
|
||||||
name: iching-service
|
name: iching-service
|
||||||
port:
|
port:
|
||||||
number: 81
|
number: 81
|
||||||
|
|
||||||
|
# Frontend → mit Rewrite
|
||||||
- path: /iching(/|$)(.*)
|
- path: /iching(/|$)(.*)
|
||||||
pathType: ImplementationSpecific
|
pathType: ImplementationSpecific
|
||||||
backend:
|
backend:
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
# 1. Node.js Build-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1 AS build
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN npm install -g npm@11.2.0
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
#RUN npx tsc -p tsconfig.json
|
|
||||||
RUN npx tsc -p tsconfig.backend.json
|
|
||||||
RUN npx tsc -p tsconfig.frontend.json
|
|
||||||
|
|
||||||
|
|
||||||
### NEW # Danach:
|
|
||||||
RUN find dist/backend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
|
||||||
|
|
||||||
|
|
||||||
# 2. Rust build-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/rust:1.74.0 AS rust-build
|
|
||||||
RUN cargo install iching
|
|
||||||
|
|
||||||
# 3. Final runtime
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
### NEW ###
|
|
||||||
COPY --from=build /app/node_modules ./node_modules
|
|
||||||
|
|
||||||
COPY --from=build /app/dist ./dist
|
|
||||||
#COPY --from=build /app/index.html ./dist/
|
|
||||||
COPY --from=build /app/frontend/index.html ./dist/frontend/
|
|
||||||
|
|
||||||
COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching
|
|
||||||
|
|
||||||
RUN find dist/backend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
|
||||||
RUN find dist/frontend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
|
||||||
|
|
||||||
RUN node dist/backend/server.mjs &
|
|
||||||
|
|
||||||
#CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"]
|
|
||||||
CMD ["npx", "http-server", "dist/frontend", "-p", "8080", "--mime", "application/javascript=js"]
|
|
|
@ -1,45 +0,0 @@
|
||||||
# 1. Node.js Build-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1 AS build
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
COPY tsconfig.json ./
|
|
||||||
COPY tsconfig.backend.json ./
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN npm install -g npm@11.2.0
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Kompiliere zuerst den Backend-Code, sodass broker.mjs und andere Dateien erzeugt werden
|
|
||||||
RUN npx tsc -p tsconfig.backend.json
|
|
||||||
|
|
||||||
# Danach können wir die Frontend-Dateien auch kompilieren
|
|
||||||
RUN npx tsc -p tsconfig.frontend.json
|
|
||||||
|
|
||||||
# 2. Rust build-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/rust:1.74.0 AS rust-build
|
|
||||||
RUN cargo install iching
|
|
||||||
|
|
||||||
# 3. Final runtime
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Kopiere Node-Modules und alle generierten Dateien
|
|
||||||
COPY --from=build /app/node_modules ./node_modules
|
|
||||||
COPY --from=build /app/dist ./dist
|
|
||||||
COPY --from=build /app/frontend/index.html ./dist/frontend/
|
|
||||||
|
|
||||||
COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching
|
|
||||||
|
|
||||||
# Falls notwendig: Umbenennen von .js zu .mjs
|
|
||||||
#RUN find dist/backend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
|
||||||
RUN find dist/frontend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
|
||||||
|
|
||||||
# Starte den Backend-Server
|
|
||||||
#RUN node dist/backend/server.js &
|
|
||||||
CMD ["node", "--loader", "ts-node/esm", "/app/dist/backend/server.js"]
|
|
||||||
|
|
||||||
# Starte den Frontend-Server
|
|
||||||
CMD ["npx", "http-server", "dist/frontend", "-p", "8080", "--mime", "application/javascript=js"]
|
|
|
@ -1,48 +0,0 @@
|
||||||
# 1. Node.js Build-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1 AS build
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN npm install -g npm@11.2.0
|
|
||||||
|
|
||||||
#RUN npx tsc
|
|
||||||
#RUN npx tsc -p tsconfig.json
|
|
||||||
#RUN npx tsc event.ts
|
|
||||||
#RUN npx tsc broker.ts
|
|
||||||
#RUN npx tsc server.ts
|
|
||||||
RUN npx tsc -p tsconfig.json
|
|
||||||
|
|
||||||
RUN cp index.html dist/
|
|
||||||
|
|
||||||
|
|
||||||
# 2. Rust build-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/rust:1.74.0 AS rust-build
|
|
||||||
RUN cargo install iching
|
|
||||||
|
|
||||||
|
|
||||||
# 3. Final node.js runtime-Stage
|
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
|
|
||||||
# 4. Copy previous builds
|
|
||||||
COPY --from=build /app .
|
|
||||||
COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching
|
|
||||||
|
|
||||||
# Lege das /iching-Verzeichnis in dist an
|
|
||||||
RUN mkdir -p dist/iching
|
|
||||||
|
|
||||||
# Kopiere HTML und JS-Dateien hinein
|
|
||||||
RUN cp index.html dist/iching/
|
|
||||||
RUN cp dist/*.js dist/iching/
|
|
||||||
|
|
||||||
|
|
||||||
# 5. Run server & app
|
|
||||||
|
|
||||||
RUN node server.js
|
|
||||||
|
|
||||||
CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"]
|
|
|
@ -11,6 +11,13 @@ spec:
|
||||||
- host: 192-168-197-2.c-one-infra.de
|
- host: 192-168-197-2.c-one-infra.de
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
|
- path: /iching/api(/|$)(.*)
|
||||||
|
pathType: ImplementationSpecific
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: iching-service
|
||||||
|
port:
|
||||||
|
number: 81
|
||||||
- path: /iching(/|$)(.*)
|
- path: /iching(/|$)(.*)
|
||||||
pathType: ImplementationSpecific
|
pathType: ImplementationSpecific
|
||||||
backend:
|
backend:
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: iching-service
|
|
||||||
namespace: argocd
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: iching-broker
|
|
||||||
ports:
|
|
||||||
- protocol: TCP
|
|
||||||
port: 80
|
|
||||||
targetPort: 8080
|
|
||||||
type: ClusterIP
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "./dist/backend", // Zielordner für die kompilierte Backend-Dateien
|
|
||||||
"rootDir": "./backend", // Quellordner
|
|
||||||
"module": "NodeNext", // Nutze ES-Modul für Node.js
|
|
||||||
"moduleResolution": "NodeNext", // NodeNext für die Modulauflösung
|
|
||||||
"target": "ES2020", // Zielversion
|
|
||||||
"esModuleInterop": true, // Interoperabilität mit CommonJS und ES-Modulen
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"allowJs": true, // Erlaubt es, .js und .mjs Dateien zu importieren
|
|
||||||
"noEmit": false, // Dateien sollen tatsächlich erzeugt werden (keine Deklarationsdateien)
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"jsx": "react",
|
|
||||||
"isolatedModules": true
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"backend/**/*.ts"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "./dist/backend",
|
|
||||||
"rootDir": "./backend",
|
|
||||||
"module": "NodeNext",
|
|
||||||
"moduleResolution": "NodeNext",
|
|
||||||
"target": "ES2020",
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"skipLibCheck": true
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"backend/broker.ts"
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in a new issue