add http-server part 7.1
This commit is contained in:
parent
11c292e072
commit
fb6972b430
6 changed files with 91 additions and 30 deletions
12
Dockerfile
12
Dockerfile
|
@ -6,16 +6,17 @@ WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
COPY tsconfig.backend.json ./
|
COPY tsconfig.backend.json ./
|
||||||
|
COPY tsconfig.broker.json ./
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm install -g npm@11.2.0
|
RUN npm install -g npm@11.2.0
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Kompiliere zuerst den Backend-Code, sodass broker.mjs und andere Dateien erzeugt werden
|
# Zuerst broker.ts zu broker.mjs kompilieren
|
||||||
RUN npx tsc -p tsconfig.backend.json
|
#RUN npx tsc -p tsconfig.broker.json
|
||||||
|
|
||||||
# Danach können wir die Frontend-Dateien auch kompilieren
|
# Danach server.ts kompilieren, nachdem broker.mjs existiert
|
||||||
RUN npx tsc -p tsconfig.frontend.json
|
RUN npx tsc -p tsconfig.backend.json
|
||||||
|
|
||||||
# 2. Rust build-Stage
|
# 2. Rust build-Stage
|
||||||
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/rust:1.74.0 AS rust-build
|
FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/rust:1.74.0 AS rust-build
|
||||||
|
@ -34,11 +35,10 @@ COPY --from=build /app/frontend/index.html ./dist/frontend/
|
||||||
COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching
|
COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching
|
||||||
|
|
||||||
# Falls notwendig: Umbenennen von .js zu .mjs
|
# 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"' {} \;
|
RUN find dist/frontend -name "*.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
|
||||||
|
|
||||||
# Starte den Backend-Server
|
# Starte den Backend-Server
|
||||||
RUN node dist/backend/server.mjs &
|
CMD ["node", "--loader", "ts-node/esm", "/app/dist/backend/server.js"]
|
||||||
|
|
||||||
# Starte den Frontend-Server
|
# Starte den Frontend-Server
|
||||||
CMD ["npx", "http-server", "dist/frontend", "-p", "8080", "--mime", "application/javascript=js"]
|
CMD ["npx", "http-server", "dist/frontend", "-p", "8080", "--mime", "application/javascript=js"]
|
|
@ -1,7 +1,7 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { executeCommand } from './broker.js';
|
import { executeCommand } from './broker.js';
|
||||||
//import { executeCommand } from './broker';
|
//import { executeCommand } from './broker';
|
||||||
|
//import { executeCommand } from './broker.mjs';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = 8080;
|
const port = 8080;
|
||||||
|
|
45
old.3.Dockerfile
Normal file
45
old.3.Dockerfile
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# 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,19 +1,21 @@
|
||||||
{
|
{
|
||||||
"extends": "./tsconfig.json", // Falls du eine allgemeine tsconfig hast
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/backend", // Zielordner für die kompilierte Backend-Dateien
|
"outDir": "./dist/backend", // Zielordner für die kompilierte Backend-Dateien
|
||||||
"rootDir": "./backend",
|
"rootDir": "./backend", // Quellordner
|
||||||
"module": "NodeNext", // Setze das Modul auf NodeNext
|
"module": "NodeNext", // Nutze ES-Modul für Node.js
|
||||||
"moduleResolution": "NodeNext", // NodeNext für die Modulauflösung
|
"moduleResolution": "NodeNext", // NodeNext für die Modulauflösung
|
||||||
"target": "ES2020", // Moderne JavaScript-Syntax verwenden
|
"target": "ES2020", // Zielversion
|
||||||
"esModuleInterop": true, // Interoperabilität mit CommonJS- und ES-Modulen
|
"esModuleInterop": true, // Interoperabilität mit CommonJS und ES-Modulen
|
||||||
"allowSyntheticDefaultImports": true, // Synthetische Default-Imports erlauben
|
"allowSyntheticDefaultImports": true,
|
||||||
"allowImportingTsExtensions": true,
|
"skipLibCheck": true,
|
||||||
"skipLibCheck": true, // Bibliotheken werden nicht überprüft (Optional)
|
"allowJs": true, // Erlaubt es, .js und .mjs Dateien zu importieren
|
||||||
"emitDeclarationOnly": true,
|
"noEmit": false, // Dateien sollen tatsächlich erzeugt werden (keine Deklarationsdateien)
|
||||||
"composite": true
|
"resolveJsonModule": true,
|
||||||
|
"jsx": "react",
|
||||||
|
"isolatedModules": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"backend/**/*.ts" // Nur Dateien im backend-Ordner kompilieren
|
"backend/**/*.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/backend",
|
"outDir": "./dist/backend",
|
||||||
"rootDir": "./backend",
|
"rootDir": "./backend",
|
||||||
"target": "ES2020",
|
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
|
"target": "ES2020",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"include": ["backend/**/*.ts"]
|
"include": [
|
||||||
|
"backend/**/*.ts"
|
||||||
|
]
|
||||||
}
|
}
|
14
tsconfig.broker.json
Normal file
14
tsconfig.broker.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"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