diff --git a/Dockerfile b/Dockerfile index 26eef39..c565646 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,32 +6,31 @@ WORKDIR /app COPY package*.json ./ COPY . . -#RUN npm install RUN npm install -g npm@11.2.0 RUN npx tsc - -### NEW ### -#RUN npm install -g http-server RUN npx tsc event.ts RUN npx tsc broker.ts +RUN npx tsc server.ts 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 @@ -40,10 +39,8 @@ RUN cp index.html dist/iching/ RUN cp dist/*.js dist/iching/ -# 5. Run app +# 5. Run server & app + +RUN node server.js -#CMD ["npx", "http-server", ".", "-p", "8080"] -#CMD ["npx", "http-server", "dist", "-p", "8080"] -#CMD ["npx", "http-server", "dist/iching", "-p", "8080", "--mime", "application/javascript=js"] -#CMD ["npx", "http-server", "dist/iching", "-p", "8080", "--mime", "application/javascript=js", "-S", "false"] CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"] diff --git a/event.ts b/event.ts index 5ae21b2..19cc125 100644 --- a/event.ts +++ b/event.ts @@ -4,7 +4,10 @@ function handleClick(): void { console.log("Der Button wurde geklickt!"); alert("Hallo von TypeScript!"); - executeCommand(); + //executeCommand(); + fetch("/api/command", { method: "POST" }) + .then(res => res.text()) + .then(text => console.log("Server sagt:", text)); } document.addEventListener("DOMContentLoaded", () => { diff --git a/server.ts b/server.ts new file mode 100644 index 0000000..231c960 --- /dev/null +++ b/server.ts @@ -0,0 +1,15 @@ +// backend/server.ts +import express from 'express'; +import { executeCommand } from './broker'; + +const app = express(); +const port = 8080; + +app.post('/api/command', (req, res) => { + executeCommand(); + res.status(200).send('Command executed'); +}); + +app.listen(port, () => { + console.log(`Server läuft auf http://localhost:${port}`); +}); \ No newline at end of file