diff --git a/Dockerfile b/Dockerfile index a88552d8..132ad498 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,11 +17,10 @@ COPY ./pnpm-workspace.yaml ./ RUN pnpm fetch --no-scripts COPY ./package*.json ./ -COPY ./packages ./packages +COPY ./packages/shared ./packages/shared RUN pnpm install -r --prefer-offline COPY ./src ./src -COPY ./esbuild.js ./esbuild.js COPY ./tsconfig.json ./tsconfig.json COPY ./next.config.mjs ./next.config.mjs COPY ./public ./public @@ -32,11 +31,11 @@ RUN npm run build # APP FROM node_base AS app +ENV NODE_ENV production # USER node WORKDIR /app -COPY --from=builder /app/dist ./ COPY --from=builder /app/next.config.mjs ./ COPY --from=builder /app/public ./public COPY --from=builder /app/package.json ./package.json diff --git a/Dockerfile.dev b/Dockerfile.dev index d941ccd5..b808d2eb 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -11,12 +11,10 @@ COPY ./pnpm-lock.yaml ./ RUN pnpm fetch --ignore-scripts COPY ./package*.json ./ -COPY ./packages ./packages +COPY ./packages/shared ./packages/shared RUN pnpm install -r --prefer-offline -COPY ./nodemon.json ./nodemon.json -COPY ./esbuild.js ./esbuild.js COPY ./tsconfig.json ./tsconfig.json COPY ./next.config.mjs ./next.config.mjs COPY ./public ./public diff --git a/esbuild.js b/esbuild.js deleted file mode 100644 index 3cea2f29..00000000 --- a/esbuild.js +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable @typescript-eslint/no-var-requires */ -const esbuild = require('esbuild'); -const { spawn } = require('child_process'); -const pkg = require('./package.json'); - -const isDev = process.argv[2] !== 'build'; - -process.env.NODE_ENV = isDev ? 'development' : 'production'; - -let server; -const onRebuild = () => { - if (isDev) { - if (server) server.kill('SIGINT'); - server = spawn('node', ['dist/index.js'], { stdio: [0, 1, 2] }); - } else { - spawn('pnpm', ['next', 'build'], { stdio: [0, 1, 2] }); - } -}; - -const included = ['express', 'pg', '@runtipi/postgres-migrations', 'connect-redis', 'express-session', 'drizzle-orm', '@runtipi/shared']; -const excluded = ['pg-native', '*required-server-files.json']; -const external = Object.keys(pkg.dependencies || {}).filter((dep) => !included.includes(dep)); -external.push(...excluded); - -esbuild - .build({ - entryPoints: ['src/server/index.ts'], - external, - define: { 'process.env.NODE_ENV': `"${process.env.NODE_ENV}"` }, - platform: 'node', - target: 'node18', - outfile: 'dist/index.js', - tsconfig: 'tsconfig.json', - bundle: true, - minify: true, - sourcemap: isDev, - watch: false, - }) - .finally(onRebuild); diff --git a/nodemon.json b/nodemon.json deleted file mode 100644 index d74f660b..00000000 --- a/nodemon.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "watch": ["src/server", "packages/shared"], - "exec": "node ./esbuild.js dev", - "ext": "js ts" -} diff --git a/package.json b/package.json index 52aed3ab..0ba6d7cb 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,6 @@ "@vitejs/plugin-react": "^4.0.1", "@vitest/coverage-v8": "^0.32.2", "dotenv-cli": "^7.2.1", - "esbuild": "^0.16.17", "eslint": "8.43.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.0.0", @@ -141,7 +140,6 @@ "memfs": "^4.2.0", "msw": "^1.2.2", "next-router-mock": "^0.9.7", - "nodemon": "^2.0.22", "prettier": "^2.8.8", "supertest": "^6.3.3", "ts-jest": "^29.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 56cfa0e9..c00289f6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -257,9 +257,6 @@ importers: dotenv-cli: specifier: ^7.2.1 version: 7.2.1 - esbuild: - specifier: ^0.16.17 - version: 0.16.17 eslint: specifier: 8.43.0 version: 8.43.0 @@ -320,9 +317,6 @@ importers: next-router-mock: specifier: ^0.9.7 version: 0.9.7(next@13.4.7)(react@18.2.0) - nodemon: - specifier: ^2.0.22 - version: 2.0.22 prettier: specifier: ^2.8.8 version: 2.8.8 @@ -331,7 +325,7 @@ importers: version: 6.3.3 ts-jest: specifier: ^29.1.0 - version: 29.1.0(@babel/core@7.22.5)(esbuild@0.16.17)(jest@29.5.0)(typescript@5.1.5) + version: 29.1.0(@babel/core@7.22.5)(jest@29.5.0)(typescript@5.1.5) ts-node: specifier: ^10.9.1 version: 10.9.1(@types/node@20.3.2)(typescript@5.1.5) @@ -425,7 +419,7 @@ importers: version: 8.8.0(eslint@8.43.0) memfs: specifier: ^4.2.0 - version: 4.2.0(quill-delta@5.1.0)(rxjs@7.8.1)(tslib@2.5.3) + version: 4.2.0(quill-delta@5.1.0)(rxjs@7.8.1)(tslib@2.6.2) nodemon: specifier: ^2.0.22 version: 2.0.22 @@ -7745,6 +7739,22 @@ packages: tslib: 2.5.3 dev: true + /json-joy@9.3.0(quill-delta@5.1.0)(rxjs@7.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-ZQiyMcbcfqki5Bsk0kWfne/Ixl4Q6cLBzCd3VE/TSp7jhns/WDBrIMTuyzDfwmLxuFtQdojiLSLX8MxTyK23QA==} + engines: {node: '>=10.0'} + hasBin: true + peerDependencies: + quill-delta: ^5 + rxjs: '7' + tslib: '2' + dependencies: + arg: 5.0.2 + hyperdyperid: 1.2.0 + quill-delta: 5.1.0 + rxjs: 7.8.1 + tslib: 2.6.2 + dev: true + /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} @@ -8202,6 +8212,20 @@ packages: - rxjs dev: true + /memfs@4.2.0(quill-delta@5.1.0)(rxjs@7.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-V5/xE+zl6+soWxlBjiVTQSkfXybTwhEBj2I8sK9LaS5lcZsTuhRftakrcRpDY7Ycac2NTK/VzEtpKMp+gpymrQ==} + engines: {node: '>= 4.0.0'} + peerDependencies: + tslib: '2' + dependencies: + json-joy: 9.3.0(quill-delta@5.1.0)(rxjs@7.8.1)(tslib@2.6.2) + thingies: 1.12.0(tslib@2.6.2) + tslib: 2.6.2 + transitivePeerDependencies: + - quill-delta + - rxjs + dev: true + /memoize-one@6.0.0: resolution: {integrity: sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==} dev: false @@ -10594,6 +10618,15 @@ packages: tslib: 2.5.3 dev: true + /thingies@1.12.0(tslib@2.6.2): + resolution: {integrity: sha512-AiGqfYC1jLmJagbzQGuoZRM48JPsr9yB734a7K6wzr34NMhjUPrWSQrkF7ZBybf3yCerCL2Gcr02kMv4NmaZfA==} + engines: {node: '>=10.18'} + peerDependencies: + tslib: ^2 + dependencies: + tslib: 2.6.2 + dev: true + /thirty-two@1.0.2: resolution: {integrity: sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==} engines: {node: '>=0.2.6'} @@ -10710,7 +10743,7 @@ packages: resolution: {integrity: sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==} dev: false - /ts-jest@29.1.0(@babel/core@7.22.5)(esbuild@0.16.17)(jest@29.5.0)(typescript@5.1.5): + /ts-jest@29.1.0(@babel/core@7.22.5)(jest@29.5.0)(typescript@5.1.5): resolution: {integrity: sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -10733,7 +10766,6 @@ packages: dependencies: '@babel/core': 7.22.5 bs-logger: 0.2.6 - esbuild: 0.16.17 fast-json-stable-stringify: 2.1.0 jest: 29.5.0(@types/node@20.3.2)(ts-node@10.9.1) jest-util: 29.5.0 @@ -10805,6 +10837,10 @@ packages: /tslib@2.5.3: resolution: {integrity: sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==} + /tslib@2.6.2: + resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + dev: true + /tsutils@3.21.0(typescript@5.1.5): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'}