我想对接我的应用程序(Prisma 4. 9. 1,NextJS 12,PostgreSQL)。想法是,你可以克隆repo,输入docker-compose up
,一切都很好。
问题是:我不知道把npx prisma db push
放在哪里。我已经尝试了多个位置,但它不工作。有什么想法吗?
- 停靠文件:**
FROM node:18 AS dependencies
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn
FROM node:18 AS build
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
RUN npx prisma generate
RUN yarn build:in:docker
FROM node:18 AS deploy
WORKDIR /app
ENV NODE_ENV production
COPY --from=build /app/public ./public
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/prisma ./prisma
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]
- 停靠-编写. yml**
version: '3.9'
services:
postgres:
image: postgres:latest
container_name: postgres
hostname: myhost
ports:
- 5432:5432
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: splitmate
volumes:
- postgres-data:/var/lib/postgresql/data
restart: unless-stopped
splitmate-app:
image: splitmate
build:
context: .
dockerfile: Dockerfile
target: deploy
volumes:
- postgres-data:/app/postgres-data
environment:
DATABASE_URL: postgresql://root:password@myhost:5432/splitmate?schema=public&connect_timeout=60
ports:
- 3000:3000
volumes:
postgres-data:
容器被构建并启动,但是当代码试图访问数据库时,我得到了这个错误:
features-splitmate-app-1 | Invalid `prisma.account.findUnique()` invocation:
features-splitmate-app-1 |
features-splitmate-app-1 |
features-splitmate-app-1 | The table `public.Account` does not exist in the current database. {
features-splitmate-app-1 | message: '\n' +
features-splitmate-app-1 | 'Invalid `prisma.account.findUnique()` invocation:\n' +
features-splitmate-app-1 | '\n' +
features-splitmate-app-1 | '\n' +
features-splitmate-app-1 | 'The table `public.Account` does not exist in the current database.',
features-splitmate-app-1 | stack: 'Error: \n' +
features-splitmate-app-1 | 'Invalid `prisma.account.findUnique()` invocation:\n' +
features-splitmate-app-1 | '\n' +
features-splitmate-app-1 | '\n' +
features-splitmate-app-1 | 'The table `public.Account` does not exist in the current database.\n' +
features-splitmate-app-1 | ' at RequestHandler.handleRequestError (/app/node_modules/@prisma/client/runtime/index.js:31941:13)\n' +
features-splitmate-app-1 | ' at RequestHandler.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/index.js:31913:12)\n' +
features-splitmate-app-1 | ' at RequestHandler.request (/app/node_modules/@prisma/client/runtime/index.js:31908:12)\n' +
features-splitmate-app-1 | ' at async PrismaClient._request (/app/node_modules/@prisma/client/runtime/index.js:32994:16)\n' +
features-splitmate-app-1 | ' at async getUserByAccount (/app/node_modules/@next-auth/prisma-adapter/dist/index.js:11:29)',
features-splitmate-app-1 | name: 'Error'
features-splitmate-app-1 | }
1条答案
按热度按时间wz1wpwve1#
我找到了解决办法