From 7919d9e3c1cf366f4ae03484baaf3c058c97ceb0 Mon Sep 17 00:00:00 2001 From: istiopaxx Date: Fri, 24 Nov 2023 01:15:10 +0900 Subject: [PATCH] [Fix]: include prisma query engine to docker image --- api/Dockerfile | 3 +++ api/prisma/schema.prisma | 3 ++- api/webpack.config.js | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/Dockerfile b/api/Dockerfile index d4243a2..cd63f54 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -3,11 +3,14 @@ FROM node:20-slim WORKDIR /app RUN npm install pm2@5.3.0 -g +RUN apt-get update -y && apt-get install -y openssl COPY ./ecosystem.config.js . COPY ./dist/apps/api-bundled/image-process.proto . COPY ./dist/apps/api-bundled/main.js . +COPY ./dist/apps/api-bundled/.prisma/client/* ./node_modules/.prisma/client/ +COPY ./prisma/schema.prisma ./prisma/schema.prisma EXPOSE 8080 diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 21cc541..2b0622c 100644 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + binaryTargets = ["native", "debian-openssl-3.0.x", "linux-arm64-openssl-3.0.x"] } datasource mysql { diff --git a/api/webpack.config.js b/api/webpack.config.js index 3c7d0ad..7054168 100644 --- a/api/webpack.config.js +++ b/api/webpack.config.js @@ -1,4 +1,5 @@ const TerserPlugin = require('terser-webpack-plugin'); +const CopyWebpackPlugin = require("copy-webpack-plugin"); module.exports = (options, webpack) => { const lazyImports = [ @@ -36,6 +37,18 @@ module.exports = (options, webpack) => { }, plugins: [ ...options.plugins, + new CopyWebpackPlugin({ + patterns: [ + { + from: `./node_modules/.prisma/client/libquery*.node`, + to({ context, absoluteFilename }) { + return `./apps/api-bundled/.prisma/client/${absoluteFilename + .split('/') + .pop()}`; + }, + }, + ], + }), new webpack.IgnorePlugin({ checkResource(resource) { if (lazyImports.includes(resource)) {