iching-broker-level2/old.3.Dockerfile
Christopher Hase fb6972b430
All checks were successful
ci / build (push) Successful in 1m7s
add http-server part 7.1
2025-04-11 09:44:00 +02:00

45 lines
No EOL
1.4 KiB
Docker

# 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"]