diff --git a/Dockerfile b/Dockerfile index 5a1fa93..c0dbc65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,10 @@ COPY . . RUN npm install -g npm@11.2.0 RUN npm install -RUN npx tsc -p tsconfig.json +#RUN npx tsc -p tsconfig.json +RUN npx tsc -p tsconfig.backend.json +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 @@ -21,13 +24,22 @@ FROM forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/node:20.18.1 WORKDIR /app COPY --from=build /app/dist ./dist -#COPY --from=build /app/index.html ./dist/iching/ -COPY --from=build /app/index.html ./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 + +### NEW ### +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}.cjs"' {} \; + + RUN mkdir -p dist/iching -RUN cp dist/*.js dist/iching/ +#RUN cp dist/*.js dist/iching/ -RUN node server.js +#RUN node dist/iching/server.js +RUN node dist/backend/server.mjs & -CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"] \ No newline at end of file +#CMD ["npx", "http-server", "dist", "-p", "8080", "--mime", "application/javascript=js"] +CMD ["npx", "http-server", "dist/frontend", "-p", "8080", "--mime", "application/javascript=js"] \ No newline at end of file diff --git a/broker.test.ts b/backend/broker.test.ts similarity index 97% rename from broker.test.ts rename to backend/broker.test.ts index 91853d6..d3766ab 100644 --- a/broker.test.ts +++ b/backend/broker.test.ts @@ -1,4 +1,4 @@ -import { html } from "./broker"; +/*import { html } from "./broker"; import { test, beforeAll, afterAll } from "@jest/globals"; jest.useFakeTimers(); @@ -17,3 +17,4 @@ test("Generate HTML for images", () => { expect(html("Images:\nOver the earth, the lake:\nThe image of Gathering Together.\nThus the superior man renews his weapons\nIn order to meet the unforseen.")) .toBe("

Images:

Over the earth, the lake:
The image of Gathering Together.
Thus the superior man renews his weapons
In order to meet the unforseen.

"); }); +*/ \ No newline at end of file diff --git a/broker.ts b/backend/broker.ts similarity index 100% rename from broker.ts rename to backend/broker.ts diff --git a/server.ts b/backend/server.ts similarity index 100% rename from server.ts rename to backend/server.ts diff --git a/event.ts b/frontend/event.ts similarity index 100% rename from event.ts rename to frontend/event.ts diff --git a/index.html b/frontend/index.html similarity index 100% rename from index.html rename to frontend/index.html diff --git a/package.json b/package.json index 24f67ce..f2e8275 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "keywords": [], "author": "", "license": "ISC", - "type": "commonjs", + "type": "module", "description": "", "devDependencies": { "@types/express": "^5.0.1", diff --git a/tsconfig.backend.json b/tsconfig.backend.json new file mode 100644 index 0000000..a423a25 --- /dev/null +++ b/tsconfig.backend.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/backend", + "module": "ESNext" + }, + "include": ["backend/**/*.ts"] +} \ No newline at end of file diff --git a/tsconfig.frontend.json b/tsconfig.frontend.json new file mode 100644 index 0000000..c84a2b8 --- /dev/null +++ b/tsconfig.frontend.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/frontend", + "module": "CommonJS" + }, + "include": ["frontend/**/*.ts"] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index ec2496c..3b47d56 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,9 @@ { - "compilerOptions": { - "target": "ES6", - "module": "ES6", - "moduleResolution": "Node", - "outDir": "dist", - "strict": true, - "esModuleInterop": true - } + "compilerOptions": { + "target": "es2020", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } } \ No newline at end of file