mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Fix Docker script
This commit is contained in:
parent
973e190875
commit
48ac83e858
@ -1,4 +1,3 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { builtinModules } from 'node:module';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
@ -10,19 +9,11 @@ const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const backendDir = resolve(__dirname, '..');
|
||||
|
||||
const packageJson = JSON.parse(readFileSync(resolve(backendDir, 'package.json'), 'utf-8'));
|
||||
|
||||
// Packages that must remain as runtime imports (can't be statically bundled)
|
||||
const externalPackages = [
|
||||
'@prisma/client',
|
||||
];
|
||||
|
||||
const customNoExternal = new Set([
|
||||
...Object.keys(packageJson.dependencies).filter(
|
||||
(dep) => !externalPackages.some((ext) => dep === ext || dep.startsWith(ext + '/'))
|
||||
),
|
||||
]);
|
||||
|
||||
// Node.js built-in modules that should not be bundled
|
||||
const nodeBuiltins = builtinModules.flatMap((m) => [m, `node:${m}`]);
|
||||
|
||||
@ -34,7 +25,8 @@ export default defineConfig({
|
||||
outDir: resolve(backendDir, 'dist'),
|
||||
target: 'node22',
|
||||
platform: 'node',
|
||||
noExternal: [...customNoExternal],
|
||||
// Bundle all non-Node modules into the migration artifact, except Prisma runtime.
|
||||
noExternal: true,
|
||||
inlineOnly: false,
|
||||
// Externalize Node.js builtins so they're imported rather than shimmed
|
||||
external: [...nodeBuiltins, ...externalPackages],
|
||||
|
||||
@ -75,6 +75,14 @@ COPY --from=builder --chown=node:node /app/apps/backend/.next/standalone ./
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/.next/static ./apps/backend/.next/static
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/prisma ./apps/backend/prisma
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/dist ./apps/backend/dist
|
||||
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
|
||||
COPY --from=builder --chown=node:node /app/packages/stack-shared ./node_modules/@stackframe/stack-shared
|
||||
|
||||
# prisma runtime modules are present in pnpm's virtual store; expose @prisma/client for Node resolution
|
||||
RUN set -e && \
|
||||
mkdir -p /app/node_modules/@prisma && \
|
||||
PRISMA_CLIENT_DIR=$(ls -d /app/node_modules/.pnpm/@prisma+client@*/node_modules/@prisma/client | head -n 1) && \
|
||||
ln -s "$PRISMA_CLIENT_DIR" /app/node_modules/@prisma/client
|
||||
|
||||
# Copy built dashboard
|
||||
COPY --from=builder --chown=node:node /app/apps/dashboard/.next/standalone ./
|
||||
|
||||
Loading…
Reference in New Issue
Block a user