Error in deployment
raamponsah
HOBBYOP

2 years ago

This is my dockerfile contents for my nextjs typescript prisma project:

Use the official Node.js 18 image as the base image

FROM node:18

Set the working directory

WORKDIR /app

Copy the package.json and package-lock.json files

COPY package*.json ./

Install dependencies with --no-optional flag and use cache mounts

Ensure cache keys are prefixed correctly as per the platform requirements

RUN --mount=type=cache,id=railway-npm-cache,target=/root/.npm
--mount=type=cache,id=railway-node-modules-cache,target=/app/node_modules
npm install --omit=dev --no-optional

Copy the rest of the application code

COPY . .

Ensure the schema.prisma file is in the correct location or specify its path

ARG SCHEMA_PATH=./prisma/schema.prisma

Generate Prisma client

RUN npx prisma generate --schema=${SCHEMA_PATH}

Apply Prisma migrations

RUN npx prisma migrate deploy --schema=${SCHEMA_PATH}

Set environment variable to disable CI mode

ENV CI=false

Build the Next.js application with cache for .next/cache

RUN --mount=type=cache,id=railway-next-cache,target=/app/.next/cache
npm run build

Expose the port the app runs on

EXPOSE 3000

Start the Next.js application

CMD ["npm", "start"]

But I get this error when I deploy: [Region: us-west1]

Cache mount ID is not prefixed with cache key

if I don't use the dockerfile I rather get this error: Dockerfile:24

22 | # build phase

23 | COPY . /app/.

24 | >>> RUN --mount=type=cache,id=s/03981ae5-d88a-43d7-8765-01a051a68a67-next/cache,target=/app/.next/cache --mount=type=cache,id=s/03981ae5-d88a-43d7-8765-01a051a68a67-nodemodules/cache,target=/app/nodemodules/.cache npm install --omit=dev && prisma generate && prisma migrate deploy && CI=false && next build

25 |

26 |

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm install --omit=dev && prisma generate && prisma migrate deploy && CI=false\u00a0&&\u00a0next\u00a0build" did not complete successfully: exit code: 1

Error: Docker build failed

Solved

2 Replies

2 years ago

We ask that you not open private threads unless you will need to share sensitive information with the team, thank you for understanding.

Please attach your Dockerfile to a message as it is very hard to digest without code formatting.


Bump, do you have a Dockerfile to attach?


Status changed to Solved jake over 1 year ago


Loading...