docker prisma nextjs
Unanswered
Jersey Wooly posted this in #help-forum
Jersey WoolyOP
i have a nextjs app with prisma postgresql and redis and i cannot deploy them through docker , i need some help please with the dockerfiles, cand anyone help me please ?
7 Replies
please improve the title of the post and also tell us what problem(s) you are facing
New Guinea Freshwater Crocodile
Please share the problem in detail
Jersey WoolyOP
FROM node:20.17.0-slim AS builder
WORKDIR /app
COPY package.json package-lock.json tsconfig.json prisma/schema.prisma ./
RUN npm ci
RUN npx prisma generate
COPY . .
RUN npx tsc --project tsconfig.json
RUN npm run build
FROM node:20.17.0-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/app ./app
COPY --from=builder /app/components ./components
EXPOSE 3000 3001
CMD ["npm", "run", "start:all"]
WORKDIR /app
COPY package.json package-lock.json tsconfig.json prisma/schema.prisma ./
RUN npm ci
RUN npx prisma generate
COPY . .
RUN npx tsc --project tsconfig.json
RUN npm run build
FROM node:20.17.0-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/app ./app
COPY --from=builder /app/components ./components
EXPOSE 3000 3001
CMD ["npm", "run", "start:all"]
so i have this dockerfile and i get all kind of errors from importing the files into components, if i use local @/app it s ok l otherwise i ve
49.38 ./app/components/modals/AddAccomodationModal.tsx
49.38 Module not found: Can't resolve '../inputs/Input'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/logistic/LogisticPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../GenericMultiDropdown'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../DateTimeRangePicker'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../inputs/Input'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../CustomDropdown'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38
49.38 > Build failed because of webpack errors
------
Dockerfile:12
--------------------
10 |
11 | RUN npx tsc --project tsconfig.json
12 | >>> RUN npm run build
13 |
14 | FROM node:20.17.0-slim
--------------------
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/7p459syaymlxf9hth442k3kpa
got this kind of errors
49.38 ./app/components/modals/AddAccomodationModal.tsx
49.38 Module not found: Can't resolve '../inputs/Input'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/logistic/LogisticPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../GenericMultiDropdown'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../DateTimeRangePicker'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../inputs/Input'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38 ./app/components/modals/AddActivityModal.tsx
49.38 Module not found: Can't resolve '../CustomDropdown'
49.38
49.38 https://nextjs.org/docs/messages/module-not-found
49.38
49.38 Import trace for requested module:
49.38 ./app/battalion/BattalionPage.tsx
49.38
49.38
49.38 > Build failed because of webpack errors
------
Dockerfile:12
--------------------
10 |
11 | RUN npx tsc --project tsconfig.json
12 | >>> RUN npm run build
13 |
14 | FROM node:20.17.0-slim
--------------------
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/7p459syaymlxf9hth442k3kpa
got this kind of errors
American black bear
I suggest you start by reading the logs
first read the linked article: https://nextjs.org/docs/messages/module-not-found
then go to each path that triggers the problem and see if you are importing a component that does not exisit or something similar