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:
@@ -36,6 +36,7 @@ RUN pnpm install --frozen-lockfile --prod
|
|||||||
|
|
||||||
# Copy built application from base stage
|
# Copy built application from base stage
|
||||||
COPY --from=base /app/dist ./dist
|
COPY --from=base /app/dist ./dist
|
||||||
|
COPY --from=base /app/server-dist ./server-dist
|
||||||
|
|
||||||
# Copy necessary files for runtime
|
# Copy necessary files for runtime
|
||||||
COPY --from=base /app/src/server/index.ts ./src/server/index.ts
|
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
|
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
|
# Start the application with ts-node and dedicated tsconfig for NodeNext
|
||||||
ENV TS_NODE_PROJECT=tsconfig.server.json
|
# Start the precompiled server JS (kein ts-node im Runtime)
|
||||||
CMD ["node", "--loader", "ts-node/esm", "src/server/index.ts"]
|
CMD ["node", "server-dist/index.js"]
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"check:types": "tsc --noEmit",
|
"check:types": "tsc --noEmit",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build && tsc -p tsconfig.server.build.json",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
|
18
tsconfig.server.build.json
Normal file
18
tsconfig.server.build.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user