From 257243aa0cd570d206598bb6a286c1742e7a216b Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Sat, 6 Apr 2024 23:22:45 -1000 Subject: [PATCH] Fix Docker build again --- Dockerfile | 2 +- build.ts | 7 ++++++- prisma/schema.prisma | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 47349bd6..65ceefba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Use the official Bun image (Bun doesn't run well on Musl but this seems to work) # See all versions at https://hub.docker.com/r/oven/bun/tags -FROM imbios/bun-node:1.1.2-current-alpine as base +FROM imbios/bun-node:1.1.2-current-debian as base # Install dependencies into temp directory # This will cache them and speed up future builds diff --git a/build.ts b/build.ts index b8856dcd..b9cb1ff5 100644 --- a/build.ts +++ b/build.ts @@ -26,7 +26,7 @@ await Bun.build({ target: "bun", splitting: true, minify: false, - external: ["bullmq"], + external: ["bullmq", "@prisma/client"], }).then((output) => { if (!output.success) { console.log(output.logs); @@ -37,6 +37,11 @@ await Bun.build({ // I apologize for this await $`sed -i 's|import("node_modules/|import("./node_modules/|g' dist/*.js`; +// Copy generated Prisma client to dist +await $`mkdir -p dist/node_modules/@prisma/client`; +await $`cp -r ${process.cwd()}/node_modules/@prisma/client dist/node_modules/@prisma`; +await $`cp -r ${process.cwd()}/node_modules/.prisma dist/node_modules`; + // Create pages directory // mkdir ./dist/pages await mkdir(`${process.cwd()}/dist/pages`); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 603a5a76..73227888 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,7 +1,8 @@ generator client { provider = "prisma-client-js" previewFeatures = ["postgresqlExtensions"] - binaryTargets = ["native"] + // These last two lines are important for Docker! + binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"] } generator json {