build(server): separater TS-Build für Server (server-dist) und Runtime auf Node JS statt ts-node; Dockerfile startet server-dist/index.js

This commit is contained in:
2025-10-01 22:05:01 +02:00
parent 4f901400a3
commit 9da96d7af9
3 changed files with 22 additions and 3 deletions

View File

@@ -36,6 +36,7 @@ RUN pnpm install --frozen-lockfile --prod
# Copy built application from base stage
COPY --from=base /app/dist ./dist
COPY --from=base /app/server-dist ./server-dist
# Copy necessary files for runtime
COPY --from=base /app/src/server/index.ts ./src/server/index.ts
@@ -60,5 +61,5 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })" || exit 1
# Start the application with ts-node and dedicated tsconfig for NodeNext
ENV TS_NODE_PROJECT=tsconfig.server.json
CMD ["node", "--loader", "ts-node/esm", "src/server/index.ts"]
# Start the precompiled server JS (kein ts-node im Runtime)
CMD ["node", "server-dist/index.js"]

View File

@@ -6,7 +6,7 @@
"scripts": {
"check:types": "tsc --noEmit",
"dev": "vite",
"build": "tsc -b && vite build",
"build": "tsc -b && vite build && tsc -p tsconfig.server.build.json",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"preview": "vite preview"

View File

@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.server.json",
"compilerOptions": {
"noEmit": false,
"outDir": "server-dist",
"sourceMap": false,
"declaration": false,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022"
},
"include": [
"src/server/**/*.ts",
"src/server/**/*.tsx"
]
}