R
Railway11mo ago
lasse

next.js dockerfile

So i use a dockerfile for my nextjs app, and it works and complete with success. But as soon i try to go to the url provided by railway i just get Application failed to respond
FROM node:21

WORKDIR /app

COPY package.json ./

RUN npm install

COPY . .

RUN npx prisma generate

RUN npm run build

CMD ["npm", "start"]
FROM node:21

WORKDIR /app

COPY package.json ./

RUN npm install

COPY . .

RUN npx prisma generate

RUN npm run build

CMD ["npm", "start"]
10 Replies
Percy
Percy11mo ago
Project ID: N/A
Brody
Brody11mo ago
lasse
lasseOP11mo ago
so the start cmd whould be? next start --port ${PORT-3000}
Brody
Brody11mo ago
the start script in your package.json but yes
lasse
lasseOP11mo ago
Yes alr thanks for the help! @Brody So i dont why its still not showing up. I have added the PORT as env variable. And updated the start command. its fixed
Brody
Brody11mo ago
awesome, what was the fix?
lasse
lasseOP11mo ago
Just needed to set the start cmd correctly too npx prisma genarate && npm run start and it was without Dockerfile.
Brody
Brody11mo ago
perfect!
lasse
lasseOP11mo ago
Yea!
SIMPLE MARK
SIMPLE MARK11mo ago
Also, on a sidenote, you could check out the with-docker example of Next.js which has a slightly more advanced and a lot more compact base image than a full on debian image does
Want results from more Discord servers?
Add your server