refactor: move from node --require to custom next server
This commit is contained in:
parent
d72526ab8a
commit
29c7f98a69
7 changed files with 21 additions and 45 deletions
|
@ -24,7 +24,6 @@ RUN npm run build
|
|||
WORKDIR /dashboard
|
||||
COPY ./packages/dashboard /dashboard
|
||||
RUN npm run build
|
||||
RUN npm run bundle:preload
|
||||
|
||||
FROM node:${NODE_VERSION}-buster-slim as app
|
||||
|
||||
|
@ -40,7 +39,6 @@ COPY --from=builder /api/dist /api/dist
|
|||
WORKDIR /dashboard
|
||||
COPY --from=builder /dashboard/next.config.mjs ./
|
||||
COPY --from=builder /dashboard/migrations ./migrations
|
||||
COPY --from=builder /dashboard/server-preload.js ./
|
||||
COPY --from=builder /dashboard/public ./public
|
||||
COPY --from=builder /dashboard/package.json ./package.json
|
||||
COPY --from=builder --chown=node:node /dashboard/.next/standalone ./
|
||||
|
|
|
@ -21,7 +21,4 @@ RUN npm install
|
|||
COPY ./packages/system-api /api
|
||||
COPY ./packages/dashboard /dashboard
|
||||
|
||||
WORKDIR /dashboard
|
||||
RUN npm run bundle:preload
|
||||
|
||||
WORKDIR /
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
const esbuild = require('esbuild');
|
||||
|
||||
/* Bundle server preload */
|
||||
esbuild.build({
|
||||
entryPoints: ['./server-preload.ts'],
|
||||
bundle: true,
|
||||
allowOverwrite: true,
|
||||
external: ['pg-native'],
|
||||
platform: 'node',
|
||||
target: 'node18',
|
||||
outfile: 'server-preload.js',
|
||||
logLevel: 'info',
|
||||
});
|
5
packages/dashboard/nodemon.json
Normal file
5
packages/dashboard/nodemon.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"watch": ["server.ts"],
|
||||
"exec": "ts-node --project tsconfig.server.json server.ts",
|
||||
"ext": "js ts"
|
||||
}
|
|
@ -8,13 +8,12 @@
|
|||
"test:client": "jest --colors --selectProjects client --",
|
||||
"test:server": "jest --colors --selectProjects server --",
|
||||
"postinstall": "prisma generate",
|
||||
"dev": "node --require ./server-preload.js ./node_modules/.bin/next dev",
|
||||
"dev": "nodemon",
|
||||
"build": "next build",
|
||||
"start": "NODE_ENV=production node --require ./server-preload.js server.js",
|
||||
"start": "NODE_ENV=production node server.js",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"gen": "graphql-codegen --config codegen.yml",
|
||||
"bundle:preload": "node esbuild.js"
|
||||
"gen": "graphql-codegen --config codegen.yml"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.6.8",
|
||||
|
@ -98,6 +97,7 @@
|
|||
"jest-environment-jsdom": "^29.3.1",
|
||||
"msw": "^0.49.2",
|
||||
"next-router-mock": "^0.8.0",
|
||||
"nodemon": "^2.0.15",
|
||||
"prisma": "^4.8.0",
|
||||
"ts-jest": "^29.0.3",
|
||||
"ts-node": "^10.9.1",
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import { runPostgresMigrations } from './run-migration';
|
||||
import { EventDispatcher, EventTypes } from './src/server/core/EventDispatcher';
|
||||
import { getConfig, setConfig } from './src/server/core/TipiConfig';
|
||||
|
||||
const main = async () => {
|
||||
// Run database migrations
|
||||
await runPostgresMigrations();
|
||||
|
||||
// Update app store repository
|
||||
await EventDispatcher.dispatchEventAsync(EventTypes.CLONE_REPO, [getConfig().appsRepoUrl]);
|
||||
await EventDispatcher.dispatchEventAsync(EventTypes.UPDATE_REPO, [getConfig().appsRepoUrl]);
|
||||
|
||||
// startJobs();
|
||||
setConfig('status', 'RUNNING');
|
||||
|
||||
// Start apps
|
||||
// appsService.startAllApps();
|
||||
console.info(`Config: ${JSON.stringify(getConfig(), null, 2)}`);
|
||||
};
|
||||
|
||||
main();
|
12
packages/dashboard/tsconfig.server.json
Normal file
12
packages/dashboard/tsconfig.server.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"outDir": "dist",
|
||||
"lib": ["es2019"],
|
||||
"target": "es2019",
|
||||
"isolatedModules": false,
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["server.ts"]
|
||||
}
|
Loading…
Add table
Reference in a new issue